Fix the mm-decode-content-transfer-encoding overflow better

* lisp/gnus/mm-bodies.el (mm-decode-content-transfer-encoding):
Use it.
(mm-base64-line-p): New function.
This commit is contained in:
Lars Ingebrigtsen 2022-05-01 10:20:07 +02:00
parent 2fcbc74c33
commit 159d8f7a0a

View file

@ -201,8 +201,11 @@ If TYPE is `text/plain' CRLF->LF translation may occur."
;; mailing list software by finding the final line with
;; base64 text.
(goto-char (point-max))
(when (re-search-backward "[A-Za-z0-9+/]{3,3}=?[\t ]*$" nil t)
(forward-line))
(beginning-of-line)
(while (and (not (mm-base64-line-p))
(not (bobp)))
(forward-line -1))
(forward-line 1)
(point))))
((memq encoding '(nil 7bit 8bit binary))
;; Do nothing.
@ -235,6 +238,18 @@ If TYPE is `text/plain' CRLF->LF translation may occur."
(while (search-forward "\r\n" nil t)
(replace-match "\n" t t)))))
(defun mm-base64-line-p ()
"Say whether the current line is base64."
;; This is coded in this way to avoid using regexps that may
;; overflow -- a base64 line may be megabytes long.
(save-excursion
(beginning-of-line)
(skip-chars-forward " \t")
(skip-chars-forward "A-Za-z0-9+")
(skip-chars-forward "=")
(skip-chars-forward " \t")
(eolp)))
(defun mm-decode-body (charset &optional encoding type)
"Decode the current article that has been encoded with ENCODING to CHARSET.
ENCODING is a MIME content transfer encoding.