diff options
| author | Katsumi Yamaoka | 2013-08-02 08:36:15 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2013-08-02 08:36:15 +0000 |
| commit | 707c77c122f6817dbf6ad2551de3a16792ceafcd (patch) | |
| tree | 241c54bc8bc3898f637d7707bfaddf94bda0301d /lisp | |
| parent | 3521bd09b3c11b68c009d290efb4350289f2d3e6 (diff) | |
| download | emacs-707c77c122f6817dbf6ad2551de3a16792ceafcd.tar.gz emacs-707c77c122f6817dbf6ad2551de3a16792ceafcd.zip | |
lisp/gnus/rfc2047.el (rfc2047-encode-message-header): Unify charsets into a single one used for encoding the whole text in a header
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/gnus/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/gnus/rfc2047.el | 161 |
2 files changed, 91 insertions, 75 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 4ea0830cb76..9733215b591 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-08-02 Katsumi Yamaoka <yamaoka@jpl.org> | ||
| 2 | |||
| 3 | * rfc2047.el (rfc2047-encode-message-header): Unify charsets into | ||
| 4 | a single one used for encoding the whole text in a header. | ||
| 5 | |||
| 1 | 2013-08-01 Lars Magne Ingebrigtsen <larsi@gnus.org> | 6 | 2013-08-01 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 7 | ||
| 3 | * message.el (message-ignored-news-headers): Delete X-Gnus-Delayed | 8 | * message.el (message-ignored-news-headers): Delete X-Gnus-Delayed |
diff --git a/lisp/gnus/rfc2047.el b/lisp/gnus/rfc2047.el index a9498d46e79..ebf597423b8 100644 --- a/lisp/gnus/rfc2047.el +++ b/lisp/gnus/rfc2047.el | |||
| @@ -235,85 +235,96 @@ Should be called narrowed to the head of the message." | |||
| 235 | (interactive "*") | 235 | (interactive "*") |
| 236 | (save-excursion | 236 | (save-excursion |
| 237 | (goto-char (point-min)) | 237 | (goto-char (point-min)) |
| 238 | (let (alist elem method) | 238 | (let (alist elem method charsets) |
| 239 | (while (not (eobp)) | 239 | (while (not (eobp)) |
| 240 | (save-restriction | 240 | (save-restriction |
| 241 | (rfc2047-narrow-to-field) | 241 | (rfc2047-narrow-to-field) |
| 242 | (setq method nil | 242 | (setq method nil |
| 243 | alist rfc2047-header-encoding-alist) | 243 | alist rfc2047-header-encoding-alist |
| 244 | (while (setq elem (pop alist)) | 244 | charsets (mm-find-mime-charset-region (point-min) (point-max))) |
| 245 | (when (or (and (stringp (car elem)) | 245 | ;; M$ Outlook boycotts decoding of a header if it consists |
| 246 | (looking-at (car elem))) | 246 | ;; of two or more encoded words and those charsets differ; |
| 247 | (eq (car elem) t)) | 247 | ;; it seems to decode all words in a header from a charset |
| 248 | (setq alist nil | 248 | ;; found first in the header. So, we unify the charsets into |
| 249 | method (cdr elem)))) | 249 | ;; a single one used for encoding the whole text in a header. |
| 250 | (if (not (rfc2047-encodable-p)) | 250 | (let ((mm-coding-system-priorities |
| 251 | (prog2 | 251 | (if (= (length charsets) 1) |
| 252 | (when (eq method 'address-mime) | 252 | (cons (mm-charset-to-coding-system (car charsets)) |
| 253 | (rfc2047-quote-special-characters-in-quoted-strings)) | 253 | mm-coding-system-priorities) |
| 254 | (if (and (eq (mm-body-7-or-8) '8bit) | 254 | mm-coding-system-priorities))) |
| 255 | (mm-multibyte-p) | 255 | (while (setq elem (pop alist)) |
| 256 | (mm-coding-system-p | 256 | (when (or (and (stringp (car elem)) |
| 257 | (car message-posting-charset))) | 257 | (looking-at (car elem))) |
| 258 | ;; 8 bit must be decoded. | 258 | (eq (car elem) t)) |
| 259 | (mm-encode-coding-region | 259 | (setq alist nil |
| 260 | (point-min) (point-max) | 260 | method (cdr elem)))) |
| 261 | (mm-charset-to-coding-system | 261 | (if (not (rfc2047-encodable-p)) |
| 262 | (car message-posting-charset)))) | 262 | (prog2 |
| 263 | ;; No encoding necessary, but folding is nice | 263 | (when (eq method 'address-mime) |
| 264 | (when nil | 264 | (rfc2047-quote-special-characters-in-quoted-strings)) |
| 265 | (rfc2047-fold-region | 265 | (if (and (eq (mm-body-7-or-8) '8bit) |
| 266 | (save-excursion | 266 | (mm-multibyte-p) |
| 267 | (goto-char (point-min)) | 267 | (mm-coding-system-p |
| 268 | (skip-chars-forward "^:") | 268 | (car message-posting-charset))) |
| 269 | (when (looking-at ": ") | 269 | ;; 8 bit must be decoded. |
| 270 | (forward-char 2)) | 270 | (mm-encode-coding-region |
| 271 | (point)) | 271 | (point-min) (point-max) |
| 272 | (point-max)))) | 272 | (mm-charset-to-coding-system |
| 273 | ;; We found something that may perhaps be encoded. | 273 | (car message-posting-charset)))) |
| 274 | (re-search-forward "^[^:]+: *" nil t) | 274 | ;; No encoding necessary, but folding is nice |
| 275 | (cond | 275 | (when nil |
| 276 | ((eq method 'address-mime) | 276 | (rfc2047-fold-region |
| 277 | (rfc2047-encode-region (point) (point-max))) | 277 | (save-excursion |
| 278 | ((eq method 'mime) | 278 | (goto-char (point-min)) |
| 279 | (let ((rfc2047-encoding-type 'mime)) | 279 | (skip-chars-forward "^:") |
| 280 | (rfc2047-encode-region (point) (point-max)))) | 280 | (when (looking-at ": ") |
| 281 | ((eq method 'default) | 281 | (forward-char 2)) |
| 282 | (if (and (featurep 'mule) | 282 | (point)) |
| 283 | (if (boundp 'enable-multibyte-characters) | 283 | (point-max)))) |
| 284 | (default-value 'enable-multibyte-characters)) | 284 | ;; We found something that may perhaps be encoded. |
| 285 | mail-parse-charset) | 285 | (re-search-forward "^[^:]+: *" nil t) |
| 286 | (mm-encode-coding-region (point) (point-max) | 286 | (cond |
| 287 | mail-parse-charset))) | 287 | ((eq method 'address-mime) |
| 288 | ;; We get this when CC'ing messages to newsgroups with | 288 | (rfc2047-encode-region (point) (point-max))) |
| 289 | ;; 8-bit names. The group name mail copy just got | 289 | ((eq method 'mime) |
| 290 | ;; unconditionally encoded. Previously, it would ask | 290 | (let ((rfc2047-encoding-type 'mime)) |
| 291 | ;; whether to encode, which was quite confusing for the | 291 | (rfc2047-encode-region (point) (point-max)))) |
| 292 | ;; user. If the new behavior is wrong, tell me. I have | 292 | ((eq method 'default) |
| 293 | ;; left the old code commented out below. | 293 | (if (and (featurep 'mule) |
| 294 | ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-07. | 294 | (if (boundp 'enable-multibyte-characters) |
| 295 | ;; Modified by Dave Love, with the commented-out code changed | 295 | (default-value 'enable-multibyte-characters)) |
| 296 | ;; in accordance with changes elsewhere. | 296 | mail-parse-charset) |
| 297 | ((null method) | 297 | (mm-encode-coding-region (point) (point-max) |
| 298 | (rfc2047-encode-region (point) (point-max))) | 298 | mail-parse-charset))) |
| 299 | ;;; ((null method) | 299 | ;; We get this when CC'ing messages to newsgroups with |
| 300 | ;;; (if (or (message-options-get | 300 | ;; 8-bit names. The group name mail copy just got |
| 301 | ;;; 'rfc2047-encode-message-header-encode-any) | 301 | ;; unconditionally encoded. Previously, it would ask |
| 302 | ;;; (message-options-set | 302 | ;; whether to encode, which was quite confusing for the |
| 303 | ;;; 'rfc2047-encode-message-header-encode-any | 303 | ;; user. If the new behavior is wrong, tell me. I have |
| 304 | ;;; (y-or-n-p | 304 | ;; left the old code commented out below. |
| 305 | ;;; "Some texts are not encoded. Encode anyway?"))) | 305 | ;; -- Per Abrahamsen <abraham@dina.kvl.dk> Date: 2001-10-07. |
| 306 | ;;; (rfc2047-encode-region (point-min) (point-max)) | 306 | ;; Modified by Dave Love, with the commented-out code changed |
| 307 | ;;; (error "Cannot send unencoded text"))) | 307 | ;; in accordance with changes elsewhere. |
| 308 | ((mm-coding-system-p method) | 308 | ((null method) |
| 309 | (if (or (and (featurep 'mule) | 309 | (rfc2047-encode-region (point) (point-max))) |
| 310 | (if (boundp 'enable-multibyte-characters) | 310 | ;;; ((null method) |
| 311 | (default-value 'enable-multibyte-characters))) | 311 | ;;; (if (or (message-options-get |
| 312 | (featurep 'file-coding)) | 312 | ;;; 'rfc2047-encode-message-header-encode-any) |
| 313 | (mm-encode-coding-region (point) (point-max) method))) | 313 | ;;; (message-options-set |
| 314 | ;; Hm. | 314 | ;;; 'rfc2047-encode-message-header-encode-any |
| 315 | (t))) | 315 | ;;; (y-or-n-p |
| 316 | (goto-char (point-max))))))) | 316 | ;;; "Some texts are not encoded. Encode anyway?"))) |
| 317 | ;;; (rfc2047-encode-region (point-min) (point-max)) | ||
| 318 | ;;; (error "Cannot send unencoded text"))) | ||
| 319 | ((mm-coding-system-p method) | ||
| 320 | (if (or (and (featurep 'mule) | ||
| 321 | (if (boundp 'enable-multibyte-characters) | ||
| 322 | (default-value 'enable-multibyte-characters))) | ||
| 323 | (featurep 'file-coding)) | ||
| 324 | (mm-encode-coding-region (point) (point-max) method))) | ||
| 325 | ;; Hm. | ||
| 326 | (t))) | ||
| 327 | (goto-char (point-max)))))))) | ||
| 317 | 328 | ||
| 318 | ;; Fixme: This, and the require below may not be the Right Thing, but | 329 | ;; Fixme: This, and the require below may not be the Right Thing, but |
| 319 | ;; should be safe just before release. -- fx 2001-02-08 | 330 | ;; should be safe just before release. -- fx 2001-02-08 |