emacs-diffs
[Top][All Lists]
Advanced

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

master 0fab632: Decode base64 attachments revealed by decryption.


From: Richard M. Stallman
Subject: master 0fab632: Decode base64 attachments revealed by decryption.
Date: Thu, 8 Sep 2022 18:10:34 -0400 (EDT)

branch: master
commit 0fab6328dcc46fe8733be5b9de214a2b11b79940
Author: Richard Stallman <rms@gnu.org>
Commit: Richard Stallman <rms@gnu.org>

    Decode base64 attachments revealed by decryption.
    
    * lisp/mail/rmail.el (rmail-epa-decode): New function.
    (rmail-epa-decrypt): Call rmail-epa-decode.
---
 lisp/mail/rmail.el | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 4bfec22..fed0a20 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -4614,6 +4614,9 @@ Argument MIME is non-nil if this is a mime message."
                     "> ")
              (push (rmail-epa-decrypt-1 mime) decrypts))))
 
+      ;; Decode any base64-encoded mime sections.
+      (rmail-epa-decode)
+
       (when (and decrypts (rmail-buffers-swapped-p))
        (when (y-or-n-p "Replace the original message? ")
           (when (eq major-mode 'rmail-mode)
@@ -4678,6 +4681,23 @@ Argument MIME is non-nil if this is a mime message."
       (unless decrypts
        (error "Nothing to decrypt")))))
 
+;; Decode all base64-encoded mime sections, so that this change
+;; is made in the Rmail file, not just in the viewing buffer.
+(defun rmail-epa-decode ()
+  (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")))
+        (when (looking-at "\
+Content-Type: text/[a-z]+; charset=UTF-8; format=flowed
+Content-Transfer-Encoding: base64\n")
+          (goto-char (match-end 0))
+          (let ((start (point))
+                (inhibit-read-only t))
+            (search-forward delim)
+            (forward-line -1)
+            (base64-decode-region start (point))
+            (forward-line 1)))))))
 
 ;;;;  Desktop support
 



reply via email to

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