Mercurial > emacs
comparison lisp/gnus/rfc2047.el @ 92777:1186239f19c8
(rfc2047-decode-string): Don't use `m'. Avoid mm-string-as-multibyte as well.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 12 Mar 2008 19:40:14 +0000 |
parents | 606f2d163a64 |
children | f42ef85caf91 |
comparison
equal
deleted
inserted
replaced
92776:cb44c6d29ee0 | 92777:1186239f19c8 |
---|---|
1092 | 1092 |
1093 (defun rfc2047-decode-string (string &optional address-mime) | 1093 (defun rfc2047-decode-string (string &optional address-mime) |
1094 "Decode MIME-encoded STRING and return the result. | 1094 "Decode MIME-encoded STRING and return the result. |
1095 If ADDRESS-MIME is non-nil, strip backslashes which precede characters | 1095 If ADDRESS-MIME is non-nil, strip backslashes which precede characters |
1096 other than `\"' and `\\' in quoted strings." | 1096 other than `\"' and `\\' in quoted strings." |
1097 (let ((m (mm-multibyte-p))) | 1097 ;; (let ((m (mm-multibyte-p))) |
1098 (if (string-match "=\\?" string) | 1098 (if (string-match "=\\?" string) |
1099 (with-temp-buffer | 1099 (with-temp-buffer |
1100 ;; Fixme: This logic is wrong, but seems to be required by | 1100 ;; We used to only call mm-enable-multibyte if `m' is non-nil, |
1101 ;; Gnus summary buffer generation. The value of `m' depends | 1101 ;; but this can't be the right criterion. Don't just revert this |
1102 ;; on the current buffer, not global multibyteness or that | 1102 ;; change if it encounters a bug. Please help me fix it |
1103 ;; of the string. Also the string returned should always be | 1103 ;; right instead. --Stef |
1104 ;; multibyte in a multibyte session, i.e. the buffer should | 1104 ;; The string returned should always be multibyte in a multibyte |
1105 ;; be multibyte before `buffer-string' is called. | 1105 ;; session, i.e. the buffer should be multibyte before |
1106 (when m | 1106 ;; `buffer-string' is called. |
1107 (mm-enable-multibyte)) | 1107 (mm-enable-multibyte) |
1108 (insert string) | 1108 (insert string) |
1109 (inline | 1109 (inline |
1110 (rfc2047-decode-region (point-min) (point-max) address-mime)) | 1110 (rfc2047-decode-region (point-min) (point-max) address-mime)) |
1111 (buffer-string)) | 1111 (buffer-string)) |
1112 (when address-mime | 1112 (when address-mime |
1116 (mm-enable-multibyte)) | 1116 (mm-enable-multibyte)) |
1117 (insert string) | 1117 (insert string) |
1118 (rfc2047-strip-backslashes-in-quoted-strings) | 1118 (rfc2047-strip-backslashes-in-quoted-strings) |
1119 (buffer-string)))) | 1119 (buffer-string)))) |
1120 ;; Fixme: As above, `m' here is inappropriate. | 1120 ;; Fixme: As above, `m' here is inappropriate. |
1121 (if (and m | 1121 (if (and ;; m |
1122 mail-parse-charset | 1122 mail-parse-charset |
1123 (not (eq mail-parse-charset 'us-ascii)) | 1123 (not (eq mail-parse-charset 'us-ascii)) |
1124 (not (eq mail-parse-charset 'gnus-decoded))) | 1124 (not (eq mail-parse-charset 'gnus-decoded))) |
1125 ;; `decode-coding-string' in Emacs offers a third optional | 1125 ;; `decode-coding-string' in Emacs offers a third optional |
1126 ;; arg NOCOPY to avoid consing a new string if the decoding | 1126 ;; arg NOCOPY to avoid consing a new string if the decoding |
1132 ;; want to avoid unnecessary consing. So we bypass | 1132 ;; want to avoid unnecessary consing. So we bypass |
1133 ;; `decode-coding-string' if the string is purely ASCII. | 1133 ;; `decode-coding-string' if the string is purely ASCII. |
1134 (if (and (fboundp 'detect-coding-string) | 1134 (if (and (fboundp 'detect-coding-string) |
1135 ;; string is purely ASCII | 1135 ;; string is purely ASCII |
1136 (eq (detect-coding-string string t) 'undecided)) | 1136 (eq (detect-coding-string string t) 'undecided)) |
1137 string | 1137 string |
1138 (mm-decode-coding-string string mail-parse-charset)) | 1138 (mm-decode-coding-string string mail-parse-charset)) |
1139 (mm-string-as-multibyte string))))) | 1139 (mm-string-to-multibyte string)))) ;; ) |
1140 | 1140 |
1141 (defun rfc2047-decode-address-string (string) | 1141 (defun rfc2047-decode-address-string (string) |
1142 "Decode MIME-encoded STRING and return the result. | 1142 "Decode MIME-encoded STRING and return the result. |
1143 Backslashes which precede characters other than `\"' and `\\' in quoted | 1143 Backslashes which precede characters other than `\"' and `\\' in quoted |
1144 strings are stripped." | 1144 strings are stripped." |
1159 (2 (concat string "==")) | 1159 (2 (concat string "==")) |
1160 (3 (concat string "="))))) | 1160 (3 (concat string "="))))) |
1161 | 1161 |
1162 (provide 'rfc2047) | 1162 (provide 'rfc2047) |
1163 | 1163 |
1164 ;;; arch-tag: a07fe3d4-22b5-4c4a-bd89-b1f82d5d36f6 | 1164 ;; arch-tag: a07fe3d4-22b5-4c4a-bd89-b1f82d5d36f6 |
1165 ;;; rfc2047.el ends here | 1165 ;;; rfc2047.el ends here |