emacs-diffs
[Top][All Lists]
Advanced

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

master 3365e413bd: When base64-decoding part of decrypted text, save the


From: Richard M. Stallman
Subject: master 3365e413bd: When base64-decoding part of decrypted text, save the decoding
Date: Wed, 25 Jan 2023 16:36:02 -0500 (EST)

branch: master
commit 3365e413bd9cb482849cf48e4f6c366a61326569
Author: Richard Stallman <rms@gnu.org>
Commit: Richard Stallman <rms@gnu.org>

    When base64-decoding part of decrypted text, save the decoding
      permanently if we save the decryption permanently.
    
    (rmail-epa-decode): Take arguments BEG and BACK-FROM-END to designate 
region.
    (rmail-epa-decrypt-1): Call rmail-epa-decode from here, when decrypting one
    encrypted passage.
    (rmail-epa-decrypt): Not from here.
---
 lisp/mail/rmail.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 659649b5d4..c56f4ce62d 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -4580,6 +4580,9 @@ Argument MIME is non-nil if this is a mime message."
             (current-buffer))))
       (error nil))
 
+    ;; Decode any base64-encoded material in what we just decrypted.
+    (rmail-epa-decode armor-start after-end)
+
     (list armor-start (- (point-max) after-end) mime
           armor-end-regexp
           (buffer-substring armor-start (- (point-max) after-end)))))
@@ -4622,9 +4625,6 @@ 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)
@@ -4689,12 +4689,14 @@ 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 ()
+;; Decode all base64-encoded mime sections from BEG to (Z - BACK-FROM-END),
+;; so that we save the decoding permanently in the Rmail buffer
+;; if we permanently save the decryption.
+(defun rmail-epa-decode (beg back-from-end)
   (save-excursion
-    (goto-char (point-min))
-    (while (re-search-forward "--------------[0-9a-zA-Z]+\n" nil t)
+    (goto-char beg)
+    (while (re-search-forward "--------------[0-9a-zA-Z]+\n"
+                              (- (point-max) back-from-end) t)
       ;; 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")))



reply via email to

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