emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 67a20bb4b5: Handle successive mime sections in decoding.


From: Richard M. Stallman
Subject: master 67a20bb4b5: Handle successive mime sections in decoding.
Date: Fri, 7 Oct 2022 08:18:08 -0400 (EDT)

branch: master
commit 67a20bb4b54de1faf840836015389bcc3d7a3eed
Author: Matt Armstrong <matt@rfc20.org>
Commit: Richard Stallman <rms@gnu.org>

    Handle successive mime sections in decoding.
    
    rmailsum.el (rmail-epa-decode):Handle blank lines at start.
    Handle both ending delim and another starting delim.
---
 lisp/mail/rmail.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 812e9a201b..f095d5e9c0 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -4693,15 +4693,23 @@ Argument MIME is non-nil if this is a mime message."
   (save-excursion
     (goto-char (point-min))
     (while (re-search-forward "--------------[0-9a-zA-Z]+\n" nil t)
-      (let ((delim (concat (substring (match-string 0) 0 -1) "--\n")))
+      ;; The ending delimiter is a start delimiter if another section follows.
+      ;; Otherwise it is an end delimiter, with -- affixed.
+      (let ((delim (concat (substring (match-string 0) 0 -1) "\\(\\|--\\)\n")))
         (when (looking-at "\
 Content-Type: text/[a-z]+; charset=UTF-8; format=flowed
 Content-Transfer-Encoding: base64\n")
           (goto-char (match-end 0))
+          ;; Sometimes the attachment's headers are followed by blank lines
+          (while (eolp)
+            (forward-line 1))
           (let ((start (point))
                 (inhibit-read-only t))
-            (search-forward delim)
+            (re-search-forward delim)
             (forward-line -1)
+            ;; Sometimes the attachment's contents are followed by blank lines
+            (while (save-excursion (forward-line -1) (eolp))
+              (forward-line -1))
             (base64-decode-region start (point))
             (forward-line 1)))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]