[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 159d8f7a0a: Fix the mm-decode-content-transfer-encoding overflow
From: |
Lars Ingebrigtsen |
Subject: |
master 159d8f7a0a: Fix the mm-decode-content-transfer-encoding overflow better |
Date: |
Sun, 1 May 2022 04:20:22 -0400 (EDT) |
branch: master
commit 159d8f7a0afec26382d570ad95a1a3b2559f642d
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
lisp/gnus/mm-bodies.el | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el
index 9f2f80b472..0d4237a64c 100644
--- a/lisp/gnus/mm-bodies.el
+++ b/lisp/gnus/mm-bodies.el
@@ -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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 159d8f7a0a: Fix the mm-decode-content-transfer-encoding overflow better,
Lars Ingebrigtsen <=