Mercurial > emacs
changeset 52358:7751260b3358
(rmail-convert-to-babyl-format): Detect
quoted-printable- and base64-encoded messages and decode them
automatically. Set the message's encoding from the charset=
header, if any. Decode base64-encoded messages in Mail format as
well.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Thu, 28 Aug 2003 15:11:15 +0000 |
parents | e0444201e1c2 |
children | 57f71e75a609 |
files | lisp/mail/rmail.el |
diffstat | 1 files changed, 73 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mail/rmail.el Thu Aug 28 14:08:55 2003 +0000 +++ b/lisp/mail/rmail.el Thu Aug 28 15:11:15 2003 +0000 @@ -1652,12 +1652,66 @@ (save-excursion (skip-chars-forward " \t\n") (point))) - (setq last-coding-system-used nil) - (or rmail-enable-mime - (not rmail-enable-multibyte) - (decode-coding-region start (point) - (or rmail-file-coding-system - 'undecided))) + (save-excursion + (let* ((header-end + (progn + (save-excursion + (goto-char start) + (forward-line 1) + (if (looking-at "0") + (forward-line 1) + (forward-line 2)) + (save-restriction + (narrow-to-region (point) (point-max)) + (rfc822-goto-eoh) + (point))))) + (case-fold-search t) + (quoted-printable-header-field-end + (save-excursion + (goto-char start) + (re-search-forward + "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*" + header-end t))) + (base64-header-field-end + (save-excursion + (goto-char start) + (re-search-forward + "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*" + header-end t)))) + (if quoted-printable-header-field-end + (save-excursion + (rmail-decode-quoted-printable header-end (point)) + ;; Change "quoted-printable" to "8bit", + ;; to reflect the decoding we just did. + (goto-char quoted-printable-header-field-end) + (delete-region (point) (search-backward ":")) + (insert ": 8bit"))) + (if base64-header-field-end + (save-excursion + (base64-decode-region (1+ header-end) + (- (point) 2)) + ;; Change "base64" to "8bit", to reflect the + ;; decoding we just did. + (goto-char (1+ header-end)) + (while (search-forward "\r\n" (point-max) t) + (replace-match "\n")) + (goto-char base64-header-field-end) + (delete-region (point) (search-backward ":")) + (insert ": 8bit"))) + (setq last-coding-system-used nil) + (or rmail-enable-mime + (not rmail-enable-multibyte) + (let ((mime-charset + (if (and rmail-decode-mime-charset + (save-excursion + (goto-char start) + (search-forward "\n\n" nil t) + (let ((case-fold-search t)) + (re-search-backward + rmail-mime-charset-pattern + start t)))) + (intern (downcase (match-string 1)))))) + (rmail-decode-region start (point) mime-charset))))) ;; Add an X-Coding-System: header if we don't have one. (save-excursion (goto-char start) @@ -1714,6 +1768,11 @@ (re-search-forward "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*" header-end t))) + (base64-header-field-end + (save-excursion + (re-search-forward + "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*" + header-end t))) (size ;; Get the numeric value from the Content-Length field. (save-excursion @@ -1762,6 +1821,14 @@ ;; to reflect the decoding we just did. (goto-char quoted-printable-header-field-end) (delete-region (point) (search-backward ":")) + (insert ": 8bit"))) + (if base64-header-field-end + (save-excursion + (base64-decode-region header-end (point)) + ;; Change "base64" to "8bit", to reflect the + ;; decoding we just did. + (goto-char base64-header-field-end) + (delete-region (point) (search-backward ":")) (insert ": 8bit")))) (save-excursion