Commit 17139abc authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(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.
parent a0b18738
2003-08-28 Eli Zaretskii <eliz@elta.co.il>
* mail/rmail.el (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.
2003-08-26 Glenn Morris <gmorris@ast.cam.ac.uk>
 
* mail/smtpmail.el Fix previous change:
......
......@@ -1652,12 +1652,66 @@ It returns t if it got any new messages."
(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 @@ It returns t if it got any new messages."
(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 @@ It returns t if it got any new messages."
;; 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment