From 324401792679cf31f0a331873d251254a5c7e2ca Mon Sep 17 00:00:00 2001 From: ShengHuo ZHU Date: Mon, 13 Dec 1999 15:53:29 +0000 Subject: [PATCH] Add Eric Marsden's patch. Merge several decode-entities copies. --- lisp/ChangeLog | 17 ++++++++++++++ lisp/nnslashdot.el | 19 +++++++++------- lisp/nnwarchive.el | 56 +++++++++------------------------------------- lisp/nnweb.el | 17 ++++++++++---- lisp/webmail.el | 51 ++++++++++------------------------------- 5 files changed, 63 insertions(+), 97 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0b4821620..017b7d862 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,20 @@ +1999-12-13 10:39:53 Shenghuo ZHU + + * nnweb.el (nnweb-decode-entities): Decode numerical entities. + (nnweb-decode-entities-string): New function. + + * nnwarchive.el (nnwarchive-decode-entities-string): Rename to + nnweb-* and move to nnweb.el. + * nnwarchive.el: Use nnweb-decode-entities, etc. + * webmail.el: Ditto. + + * nnslashdot.el: Use nnweb-decode-entities-string. + (nnslashdot-decode-entities): Remove. + +1999-12-13 10:40:56 Eric Marsden + + * nnslashdot.el: Decode entities. + 1999-12-12 Dave Love * gnus-agent.el (gnus-category-edit-groups) diff --git a/lisp/nnslashdot.el b/lisp/nnslashdot.el index 7ffa71104..fb2090877 100644 --- a/lisp/nnslashdot.el +++ b/lisp/nnslashdot.el @@ -108,7 +108,7 @@ (goto-char (point-min)) (search-forward "Posted by ") (when (looking-at "]+>\\([^<]+\\)") - (setq from (match-string 1))) + (setq from (nnweb-decode-entities-string (match-string 1)))) (search-forward " on ") (setq date (nnslashdot-date-to-date (buffer-substring (point) (1- (search-forward "<"))))) @@ -146,13 +146,14 @@ score (match-string 3)) (when (string-match "^Re: *" subject) (setq subject (concat "Re: " (substring subject (match-end 0))))) + (setq subject (nnweb-decode-entities-string subject)) (forward-line 1) (if (looking-at "by ]+>\\([^<]+\\)[ \t\n]*.*(\\([^)]+\\))") - (setq from (concat (match-string 1) + (setq from (concat (nnweb-decode-entities-string (match-string 1)) " <" (match-string 2) ">")) (looking-at "by \\(.+\\) on ") - (setq from (match-string 1))) + (setq from (nnweb-decode-entities-string (match-string 1)))) (goto-char (- (match-end 0) 5)) (search-forward " on ") (setq date @@ -206,7 +207,7 @@ (goto-char (point-min)) (search-forward "Posted by ") (when (looking-at "]+>\\([^<]+\\)") - (setq from (match-string 1))) + (setq from (nnweb-decode-entities-string (match-string 1)))) (search-forward " on ") (setq date (nnslashdot-date-to-date (buffer-substring (point) (1- (search-forward "<"))))) @@ -238,12 +239,14 @@ score (match-string 3)) (when (string-match "^Re: *" subject) (setq subject (concat "Re: " (substring subject (match-end 0))))) + (setq subject (nnweb-decode-entities-string subject)) (forward-line 1) (if (looking-at "by ]+>\\([^<]+\\)[ \t\n]*.*(\\([^)]+\\))") - (setq from (concat (match-string 1) " <" (match-string 2) ">")) + (setq from (concat (nnweb-decode-entities-string (match-string 1)) + " <" (match-string 2) ">")) (looking-at "by \\(.+\\) on ") - (setq from (match-string 1))) + (setq from (nnweb-decode-entities-string (match-string 1)))) (goto-char (- (match-end 0) 5)) (search-forward " on ") (setq date @@ -372,7 +375,7 @@ (narrow-to-region (point) (search-forward "")) (goto-char (point-min)) (re-search-forward "\\([^<]+\\)") - (setq description (match-string 1)) + (setq description (nnweb-decode-entities-string (match-string 1))) (re-search-forward "\\([^<]+\\)") (setq sid (match-string 1)) (string-match "/\\([0-9/]+\\).shtml" sid) @@ -394,7 +397,7 @@ (while (re-search-forward "article.pl\\?sid=\\([^&]+\\).*\\([^<]+\\)" nil t) (setq sid (match-string 1) - description (match-string 2)) + description (nnweb-decode-entities-string (match-string 2))) (forward-line 1) (when (re-search-forward "\\([0-9]+\\)" nil t) (setq articles (string-to-number (match-string 1)))) diff --git a/lisp/nnwarchive.el b/lisp/nnwarchive.el index a9d2dbb07..8c0d44366 100644 --- a/lisp/nnwarchive.el +++ b/lisp/nnwarchive.el @@ -375,42 +375,6 @@ (t (nnweb-insert (apply 'format (nnwarchive-eval xurl))))))) -(defun nnwarchive-decode-entities () - (goto-char (point-min)) - (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t) - (replace-match (char-to-string - (if (eq (aref (match-string 1) 0) ?\#) - (string-to-number (substring (match-string 1) 1)) - (or (cdr (assq (intern (match-string 1)) - w3-html-entities)) - ?#))) - t t))) - -(defun nnwarchive-decode-entities-string (str) - (with-temp-buffer - (insert str) - (nnwarchive-decode-entities) - (buffer-substring (point-min) (point-max)))) - -(defun nnwarchive-remove-markup () - (goto-char (point-min)) - (while (search-forward "" nil t) - (point-max)))) - (goto-char (point-min)) - (while (re-search-forward "<[^>]+>" nil t) - (replace-match "" t t))) - -(defun nnwarchive-date-to-date (sdate) - (let ((elem (split-string sdate))) - (concat (substring (nth 0 elem) 0 3) " " - (substring (nth 1 elem) 0 3) " " - (substring (nth 2 elem) 0 2) " " - (substring (nth 3 elem) 1 6) " " - (format-time-string "%Y") " " - (nth 4 elem)))) - (defun nnwarchive-generate-active () (save-excursion (set-buffer nntp-server-buffer) @@ -489,8 +453,8 @@ article (make-full-mail-header article - (nnwarchive-decode-entities-string subject) - (nnwarchive-decode-entities-string from) + (nnweb-decode-entities-string subject) + (nnweb-decode-entities-string from) date (concat "<" group "%" (number-to-string article) @@ -509,7 +473,7 @@ (goto-char (point-min)) (while (re-search-forward "]+>\\([^<]+\\)" nil t) (replace-match "<\\1>")) - (nnwarchive-decode-entities) + (nnweb-decode-entities) (buffer-string)) (defun nnwarchive-egroups-xover-files (group articles) @@ -578,8 +542,8 @@ article (make-full-mail-header article - (nnwarchive-decode-entities-string subject) - (nnwarchive-decode-entities-string from) + (nnweb-decode-entities-string subject) + (nnweb-decode-entities-string from) date (format "<%05d%%%s>\n" (1- article) group) "" @@ -642,7 +606,7 @@ (when (search-forward "X-Head-End" nil t) (beginning-of-line) (narrow-to-region (point-min) (point)) - (nnwarchive-decode-entities) + (nnweb-decode-entities) (goto-char (point-min)) (while (search-forward "" nil t) - (point-max)))) - (goto-char (point-min)) - (while (re-search-forward "<[^>]+>" nil t) - (replace-match "" t t))) - (defun webmail-init () "Initialize buffers and such." (if (gnus-buffer-live-p webmail-buffer) @@ -387,8 +360,8 @@ (setq p (match-beginning 0)) (search-forward "" nil t) (delete-region p (match-end 0))) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) (goto-char (point-min)) (delete-blank-lines) (goto-char (point-min)) @@ -437,8 +410,8 @@ (goto-char (match-end 0)) (if (looking-at "$") (forward-char)) (delete-region (point-min) (point)) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) nil) (t (setq mime t) @@ -529,8 +502,8 @@ (setq p (match-beginning 0)) (search-forward "" nil t) (delete-region p (match-end 0))) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) (goto-char (point-min)) (delete-blank-lines) (goto-char (point-max)) @@ -546,8 +519,8 @@ (if (not (search-forward "" nil t)) (error "Can't find start label (article@5)")) (narrow-to-region p (match-end 0)) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) (goto-char (point-min)) (delete-blank-lines) (setq ct (mail-fetch-field "content-type") @@ -641,8 +614,8 @@ (goto-char (point-min)) (while (re-search-forward "
" nil t) (replace-match "\n")) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) nil) (t (insert "<#part type=\"text/html\" disposition=inline>") @@ -668,8 +641,8 @@ (goto-char (point-min)) (while (search-forward "" nil t) (replace-match "\n")) - (webmail-remove-markup) - (webmail-decode-entities) + (nnweb-remove-markup) + (nnweb-decode-entities) (goto-char (point-min)) (delete-blank-lines) (goto-char (point-min)) -- 2.25.1