aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2006-09-01 23:52:28 +0000
committerMiles Bader2006-09-01 23:52:28 +0000
commit343d662867f2ad217c55e174ee5a58f0659543de (patch)
tree9a1e0d8097cce19d06a5c5e61538165283f704c9
parent5deb7a514ba2d12953b29fa28bbc74daeaa21c25 (diff)
downloademacs-343d662867f2ad217c55e174ee5a58f0659543de.tar.gz
emacs-343d662867f2ad217c55e174ee5a58f0659543de.zip
Merge from gnus--rel--5.10
Patches applied: * gnus--rel--5.10 (patch 128) - Update from CVS 2006-09-01 Katsumi Yamaoka <yamaoka@jpl.org> * lisp/gnus/rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings): Use standard-syntax-table. 2006-09-01 Katsumi Yamaoka <yamaoka@jpl.org> * lisp/gnus/gnus-art.el (gnus-decode-address-function): New variable. (article-decode-encoded-words): Use it to decode headers which are assumed to contain addresses. (gnus-mime-delete-part): Remove useless `or'. * lisp/gnus/gnus-sum.el (gnus-decode-encoded-address-function): New variable. (gnus-summary-from-or-to-or-newsgroups): Use it to decode To header. (gnus-nov-parse-line): Use it to decode From header. (gnus-get-newsgroup-headers): Ditto. (gnus-summary-enter-digest-group): Use it to decode `to-address'. * lisp/gnus/mail-parse.el (mail-decode-encoded-address-region): New alias. (mail-decode-encoded-address-string): New alias. * lisp/gnus/rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings): New function. (rfc2047-encode-message-header, rfc2047-encode-region): Use it. (rfc2047-strip-backslashes-in-quoted-strings): New fnction. (rfc2047-decode-region): Use it; add optional argument `address-mime'. (rfc2047-decode-string): Ditto. (rfc2047-decode-address-region): New function. (rfc2047-decode-address-string): New function. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-418
-rw-r--r--lisp/gnus/ChangeLog30
-rw-r--r--lisp/gnus/gnus-art.el25
-rw-r--r--lisp/gnus/gnus-sum.el23
-rw-r--r--lisp/gnus/mail-parse.el2
-rw-r--r--lisp/gnus/rfc2047.el114
5 files changed, 166 insertions, 28 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 6927e3bfbac..87f00faef76 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,33 @@
12006-09-01 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings):
4 Use standard-syntax-table.
5
62006-09-01 Katsumi Yamaoka <yamaoka@jpl.org>
7
8 * gnus-art.el (gnus-decode-address-function): New variable.
9 (article-decode-encoded-words): Use it to decode headers which are
10 assumed to contain addresses.
11 (gnus-mime-delete-part): Remove useless `or'.
12
13 * gnus-sum.el (gnus-decode-encoded-address-function): New variable.
14 (gnus-summary-from-or-to-or-newsgroups): Use it to decode To header.
15 (gnus-nov-parse-line): Use it to decode From header.
16 (gnus-get-newsgroup-headers): Ditto.
17 (gnus-summary-enter-digest-group): Use it to decode `to-address'.
18
19 * mail-parse.el (mail-decode-encoded-address-region): New alias.
20 (mail-decode-encoded-address-string): New alias.
21
22 * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings):
23 New function.
24 (rfc2047-encode-message-header, rfc2047-encode-region): Use it.
25 (rfc2047-strip-backslashes-in-quoted-strings): New fnction.
26 (rfc2047-decode-region): Use it; add optional argument `address-mime'.
27 (rfc2047-decode-string): Ditto.
28 (rfc2047-decode-address-region): New function.
29 (rfc2047-decode-address-string): New function.
30
12006-08-23 Andreas Seltenreich <uwi7@rz.uni-karlsruhe.de> 312006-08-23 Andreas Seltenreich <uwi7@rz.uni-karlsruhe.de>
2 32
3 [ Backported bug fix from No Gnus. ] 33 [ Backported bug fix from No Gnus. ]
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 39292e33a1f..17cbbeb0a75 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -853,6 +853,9 @@ be displayed by the first non-nil matching CONTENT face."
853(defvar gnus-decode-header-function 'mail-decode-encoded-word-region 853(defvar gnus-decode-header-function 'mail-decode-encoded-word-region
854 "Function used to decode headers.") 854 "Function used to decode headers.")
855 855
856(defvar gnus-decode-address-function 'mail-decode-encoded-address-region
857 "Function used to decode addresses.")
858
856(defvar gnus-article-dumbquotes-map 859(defvar gnus-article-dumbquotes-map
857 '(("\200" "EUR") 860 '(("\200" "EUR")
858 ("\202" ",") 861 ("\202" ",")
@@ -2377,10 +2380,23 @@ If PROMPT (the prefix), prompt for a coding system to use."
2377 (set-buffer gnus-summary-buffer) 2380 (set-buffer gnus-summary-buffer)
2378 (error)) 2381 (error))
2379 gnus-newsgroup-ignored-charsets)) 2382 gnus-newsgroup-ignored-charsets))
2380 (inhibit-read-only t)) 2383 (inhibit-read-only t)
2384 start)
2381 (save-restriction 2385 (save-restriction
2382 (article-narrow-to-head) 2386 (article-narrow-to-head)
2383 (funcall gnus-decode-header-function (point-min) (point-max))))) 2387 (while (not (eobp))
2388 (setq start (point))
2389 (if (prog1
2390 (looking-at "\
2391\\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2392\\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2393 (while (progn
2394 (forward-line)
2395 (if (eobp)
2396 nil
2397 (memq (char-after) '(?\t ? ))))))
2398 (funcall gnus-decode-address-function start (point))
2399 (funcall gnus-decode-header-function start (point)))))))
2384 2400
2385(defun article-decode-group-name () 2401(defun article-decode-group-name ()
2386 "Decode group names in `Newsgroups:'." 2402 "Decode group names in `Newsgroups:'."
@@ -4324,9 +4340,8 @@ Deleting parts may malfunction or destroy the article; continue? ")
4324 (handles gnus-article-mime-handles) 4340 (handles gnus-article-mime-handles)
4325 (none "(none)") 4341 (none "(none)")
4326 (description 4342 (description
4327 (or 4343 (mail-decode-encoded-word-string (or (mm-handle-description data)
4328 (mail-decode-encoded-word-string (or (mm-handle-description data) 4344 none)))
4329 none))))
4330 (filename 4345 (filename
4331 (or (mail-content-type-get (mm-handle-disposition data) 'filename) 4346 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4332 none)) 4347 none))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index b94d093329a..7d91d4db5aa 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -992,7 +992,11 @@ which it may alter in any way."
992 :group 'gnus-summary) 992 :group 'gnus-summary)
993 993
994(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string 994(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
995 "Variable that says which function should be used to decode a string with encoded words.") 995 "Function used to decode a string with encoded words.")
996
997(defvar gnus-decode-encoded-address-function
998 'mail-decode-encoded-address-string
999 "Function used to decode addresses with encoded words.")
996 1000
997(defcustom gnus-extra-headers '(To Newsgroups) 1001(defcustom gnus-extra-headers '(To Newsgroups)
998 "*Extra headers to parse." 1002 "*Extra headers to parse."
@@ -1001,7 +1005,7 @@ which it may alter in any way."
1001 :type '(repeat symbol)) 1005 :type '(repeat symbol))
1002 1006
1003(defcustom gnus-ignored-from-addresses 1007(defcustom gnus-ignored-from-addresses
1004 (and user-mail-address 1008 (and user-mail-address
1005 (not (string= user-mail-address "")) 1009 (not (string= user-mail-address ""))
1006 (regexp-quote user-mail-address)) 1010 (regexp-quote user-mail-address))
1007 "*Regexp of From headers that may be suppressed in favor of To headers." 1011 "*Regexp of From headers that may be suppressed in favor of To headers."
@@ -3436,7 +3440,7 @@ buffer that was in action when the last article was fetched."
3436 (concat "-> " 3440 (concat "-> "
3437 (inline 3441 (inline
3438 (gnus-summary-extract-address-component 3442 (gnus-summary-extract-address-component
3439 (funcall gnus-decode-encoded-word-function to))))) 3443 (funcall gnus-decode-encoded-address-function to)))))
3440 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers))) 3444 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3441 (concat "=> " newsgroups))))) 3445 (concat "=> " newsgroups)))))
3442 (inline (gnus-summary-extract-address-component gnus-tmp-from))))) 3446 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
@@ -4182,7 +4186,7 @@ Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4182 (error x)) 4186 (error x))
4183 (condition-case () ; from 4187 (condition-case () ; from
4184 (gnus-remove-odd-characters 4188 (gnus-remove-odd-characters
4185 (funcall gnus-decode-encoded-word-function 4189 (funcall gnus-decode-encoded-address-function
4186 (setq x (nnheader-nov-field)))) 4190 (setq x (nnheader-nov-field))))
4187 (error x)) 4191 (error x))
4188 (nnheader-nov-field) ; date 4192 (nnheader-nov-field) ; date
@@ -5956,7 +5960,7 @@ The resulting hash table is returned, or nil if no Xrefs were found."
5956 (progn 5960 (progn
5957 (goto-char p) 5961 (goto-char p)
5958 (if (search-forward "\nfrom:" nil t) 5962 (if (search-forward "\nfrom:" nil t)
5959 (funcall gnus-decode-encoded-word-function 5963 (funcall gnus-decode-encoded-address-function
5960 (nnheader-header-value)) 5964 (nnheader-header-value))
5961 "(nobody)")) 5965 "(nobody)"))
5962 ;; Date. 5966 ;; Date.
@@ -8449,10 +8453,11 @@ to guess what the document format is."
8449 ;; the parent article. 8453 ;; the parent article.
8450 (when (setq to-address (or (gnus-fetch-field "reply-to") 8454 (when (setq to-address (or (gnus-fetch-field "reply-to")
8451 (gnus-fetch-field "from"))) 8455 (gnus-fetch-field "from")))
8452 (setq params (append 8456 (setq params
8453 (list (cons 'to-address 8457 (append
8454 (funcall gnus-decode-encoded-word-function 8458 (list (cons 'to-address
8455 to-address)))))) 8459 (funcall gnus-decode-encoded-address-function
8460 to-address))))))
8456 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) 8461 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8457 (insert-buffer-substring gnus-original-article-buffer) 8462 (insert-buffer-substring gnus-original-article-buffer)
8458 ;; Remove lines that may lead nndoc to misinterpret the 8463 ;; Remove lines that may lead nndoc to misinterpret the
diff --git a/lisp/gnus/mail-parse.el b/lisp/gnus/mail-parse.el
index 6a9a4755bb2..3c1aa8111c2 100644
--- a/lisp/gnus/mail-parse.el
+++ b/lisp/gnus/mail-parse.el
@@ -70,6 +70,8 @@
70(defalias 'mail-encode-encoded-word-string 'rfc2047-encode-string) 70(defalias 'mail-encode-encoded-word-string 'rfc2047-encode-string)
71(defalias 'mail-decode-encoded-word-region 'rfc2047-decode-region) 71(defalias 'mail-decode-encoded-word-region 'rfc2047-decode-region)
72(defalias 'mail-decode-encoded-word-string 'rfc2047-decode-string) 72(defalias 'mail-decode-encoded-word-string 'rfc2047-decode-string)
73(defalias 'mail-decode-encoded-address-region 'rfc2047-decode-address-region)
74(defalias 'mail-decode-encoded-address-string 'rfc2047-decode-address-string)
73 75
74(provide 'mail-parse) 76(provide 'mail-parse)
75 77
diff --git a/lisp/gnus/rfc2047.el b/lisp/gnus/rfc2047.el
index aa30d9ba783..dc51a104c2f 100644
--- a/lisp/gnus/rfc2047.el
+++ b/lisp/gnus/rfc2047.el
@@ -171,6 +171,40 @@ This is either `base64' or `quoted-printable'."
171 (re-search-forward ":[ \t\n]*" nil t) 171 (re-search-forward ":[ \t\n]*" nil t)
172 (buffer-substring-no-properties (point) (point-max))))) 172 (buffer-substring-no-properties (point) (point-max)))))
173 173
174(defun rfc2047-quote-special-characters-in-quoted-strings (&optional
175 encodable-regexp)
176 "Quote special characters with `\\'s in quoted strings.
177Quoting will not be done in a quoted string if it contains characters
178matching ENCODABLE-REGEXP."
179 (goto-char (point-min))
180 (let ((tspecials (concat "[" ietf-drums-tspecials "]"))
181 beg)
182 (with-syntax-table (standard-syntax-table)
183 (while (search-forward "\"" nil t)
184 (unless (eq (char-before) ?\\)
185 (setq beg (match-end 0))
186 (goto-char (match-beginning 0))
187 (condition-case nil
188 (progn
189 (forward-sexp)
190 (save-restriction
191 (narrow-to-region beg (1- (point)))
192 (goto-char beg)
193 (unless (and encodable-regexp
194 (re-search-forward encodable-regexp nil t))
195 (while (re-search-forward tspecials nil 'move)
196 (unless (and (eq (char-before) ?\\) ;; Already quoted.
197 (looking-at tspecials))
198 (goto-char (match-beginning 0))
199 (unless (or (eq (char-before) ?\\)
200 (and rfc2047-encode-encoded-words
201 (eq (char-after) ??)
202 (eq (char-before) ?=)))
203 (insert "\\")))
204 (forward-char)))))
205 (error
206 (goto-char beg))))))))
207
174(defvar rfc2047-encoding-type 'address-mime 208(defvar rfc2047-encoding-type 'address-mime
175 "The type of encoding done by `rfc2047-encode-region'. 209 "The type of encoding done by `rfc2047-encode-region'.
176This should be dynamically bound around calls to 210This should be dynamically bound around calls to
@@ -187,8 +221,18 @@ Should be called narrowed to the head of the message."
187 (while (not (eobp)) 221 (while (not (eobp))
188 (save-restriction 222 (save-restriction
189 (rfc2047-narrow-to-field) 223 (rfc2047-narrow-to-field)
224 (setq method nil
225 alist rfc2047-header-encoding-alist)
226 (while (setq elem (pop alist))
227 (when (or (and (stringp (car elem))
228 (looking-at (car elem)))
229 (eq (car elem) t))
230 (setq alist nil
231 method (cdr elem))))
190 (if (not (rfc2047-encodable-p)) 232 (if (not (rfc2047-encodable-p))
191 (prog1 233 (prog2
234 (when (eq method 'address-mime)
235 (rfc2047-quote-special-characters-in-quoted-strings))
192 (if (and (eq (mm-body-7-or-8) '8bit) 236 (if (and (eq (mm-body-7-or-8) '8bit)
193 (mm-multibyte-p) 237 (mm-multibyte-p)
194 (mm-coding-system-p 238 (mm-coding-system-p
@@ -209,14 +253,6 @@ Should be called narrowed to the head of the message."
209 (point)) 253 (point))
210 (point-max)))) 254 (point-max))))
211 ;; We found something that may perhaps be encoded. 255 ;; We found something that may perhaps be encoded.
212 (setq method nil
213 alist rfc2047-header-encoding-alist)
214 (while (setq elem (pop alist))
215 (when (or (and (stringp (car elem))
216 (looking-at (car elem)))
217 (eq (car elem) t))
218 (setq alist nil
219 method (cdr elem))))
220 (re-search-forward "^[^:]+: *" nil t) 256 (re-search-forward "^[^:]+: *" nil t)
221 (cond 257 (cond
222 ((eq method 'address-mime) 258 ((eq method 'address-mime)
@@ -347,6 +383,7 @@ Dynamically bind `rfc2047-encoding-type' to change that."
347 (rfc2047-encode start (point)) 383 (rfc2047-encode start (point))
348 (goto-char end)))) 384 (goto-char end))))
349 ;; `address-mime' case -- take care of quoted words, comments. 385 ;; `address-mime' case -- take care of quoted words, comments.
386 (rfc2047-quote-special-characters-in-quoted-strings encodable-regexp)
350 (with-syntax-table rfc2047-syntax-table 387 (with-syntax-table rfc2047-syntax-table
351 (goto-char (point-min)) 388 (goto-char (point-min))
352 (condition-case err ; in case of unbalanced quotes 389 (condition-case err ; in case of unbalanced quotes
@@ -821,6 +858,29 @@ encoded-word, concatenate them, and decode it by charset. Otherwise,
821the decoder will fully decode each encoded-word before concatenating 858the decoder will fully decode each encoded-word before concatenating
822them.") 859them.")
823 860
861(defun rfc2047-strip-backslashes-in-quoted-strings ()
862 "Strip backslashes in quoted strings. `\\\"' and `\\\\' remain."
863 (goto-char (point-min))
864 (let (beg)
865 (with-syntax-table (standard-syntax-table)
866 (while (search-forward "\"" nil t)
867 (unless (eq (char-before) ?\\)
868 (setq beg (match-end 0))
869 (goto-char (match-beginning 0))
870 (condition-case nil
871 (progn
872 (forward-sexp)
873 (save-restriction
874 (narrow-to-region beg (1- (point)))
875 (goto-char beg)
876 (while (search-forward "\\" nil 'move)
877 (unless (memq (char-after) '(?\" ?\\))
878 (delete-backward-char 1))
879 (forward-char)))
880 (forward-char))
881 (error
882 (goto-char beg))))))))
883
824(defun rfc2047-charset-to-coding-system (charset) 884(defun rfc2047-charset-to-coding-system (charset)
825 "Return coding-system corresponding to MIME CHARSET. 885 "Return coding-system corresponding to MIME CHARSET.
826If your Emacs implementation can't decode CHARSET, return nil." 886If your Emacs implementation can't decode CHARSET, return nil."
@@ -898,8 +958,10 @@ ENCODED-WORD)."
898;; and worthwhile (is it more correct or not?), e.g. something like 958;; and worthwhile (is it more correct or not?), e.g. something like
899;; `=?iso-8859-1?q?foo?=@'. 959;; `=?iso-8859-1?q?foo?=@'.
900 960
901(defun rfc2047-decode-region (start end) 961(defun rfc2047-decode-region (start end &optional address-mime)
902 "Decode MIME-encoded words in region between START and END." 962 "Decode MIME-encoded words in region between START and END.
963If ADDRESS-MIME is non-nil, strip backslashes which precede characters
964other than `\"' and `\\' in quoted strings."
903 (interactive "r") 965 (interactive "r")
904 (let ((case-fold-search t) 966 (let ((case-fold-search t)
905 (eword-regexp (eval-when-compile 967 (eword-regexp (eval-when-compile
@@ -910,6 +972,8 @@ ENCODED-WORD)."
910 (save-excursion 972 (save-excursion
911 (save-restriction 973 (save-restriction
912 (narrow-to-region start end) 974 (narrow-to-region start end)
975 (when address-mime
976 (rfc2047-strip-backslashes-in-quoted-strings))
913 (goto-char (setq b start)) 977 (goto-char (setq b start))
914 ;; Look for the encoded-words. 978 ;; Look for the encoded-words.
915 (while (setq match (re-search-forward eword-regexp nil t)) 979 (while (setq match (re-search-forward eword-regexp nil t))
@@ -995,8 +1059,16 @@ ENCODED-WORD)."
995 (not (eq mail-parse-charset 'gnus-decoded))) 1059 (not (eq mail-parse-charset 'gnus-decoded)))
996 (mm-decode-coding-region b (point-max) mail-parse-charset)))))) 1060 (mm-decode-coding-region b (point-max) mail-parse-charset))))))
997 1061
998(defun rfc2047-decode-string (string) 1062(defun rfc2047-decode-address-region (start end)
999 "Decode the quoted-printable-encoded STRING and return the results." 1063 "Decode MIME-encoded words in region between START and END.
1064Backslashes which precede characters other than `\"' and `\\' in quoted
1065strings are stripped."
1066 (rfc2047-decode-region start end t))
1067
1068(defun rfc2047-decode-string (string &optional address-mime)
1069 "Decode MIME-encoded STRING and return the result.
1070If ADDRESS-MIME is non-nil, strip backslashes which precede characters
1071other than `\"' and `\\' in quoted strings."
1000 (let ((m (mm-multibyte-p))) 1072 (let ((m (mm-multibyte-p)))
1001 (if (string-match "=\\?" string) 1073 (if (string-match "=\\?" string)
1002 (with-temp-buffer 1074 (with-temp-buffer
@@ -1010,8 +1082,16 @@ ENCODED-WORD)."
1010 (mm-enable-multibyte)) 1082 (mm-enable-multibyte))
1011 (insert string) 1083 (insert string)
1012 (inline 1084 (inline
1013 (rfc2047-decode-region (point-min) (point-max))) 1085 (rfc2047-decode-region (point-min) (point-max) address-mime))
1014 (buffer-string)) 1086 (buffer-string))
1087 (when address-mime
1088 (setq string
1089 (with-temp-buffer
1090 (when (mm-multibyte-string-p string)
1091 (mm-enable-multibyte))
1092 (insert string)
1093 (rfc2047-strip-backslashes-in-quoted-strings)
1094 (buffer-string))))
1015 ;; Fixme: As above, `m' here is inappropriate. 1095 ;; Fixme: As above, `m' here is inappropriate.
1016 (if (and m 1096 (if (and m
1017 mail-parse-charset 1097 mail-parse-charset
@@ -1033,6 +1113,12 @@ ENCODED-WORD)."
1033 (mm-decode-coding-string string mail-parse-charset)) 1113 (mm-decode-coding-string string mail-parse-charset))
1034 (mm-string-as-multibyte string))))) 1114 (mm-string-as-multibyte string)))))
1035 1115
1116(defun rfc2047-decode-address-string (string)
1117 "Decode MIME-encoded STRING and return the result.
1118Backslashes which precede characters other than `\"' and `\\' in quoted
1119strings are stripped."
1120 (rfc2047-decode-string string t))
1121
1036(defun rfc2047-pad-base64 (string) 1122(defun rfc2047-pad-base64 (string)
1037 "Pad STRING to quartets." 1123 "Pad STRING to quartets."
1038 ;; Be more liberal to accept buggy base64 strings. If 1124 ;; Be more liberal to accept buggy base64 strings. If