summaryrefslogtreecommitdiff
path: root/lisp/mail/rmail.el
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>2019-02-24 10:45:34 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-02-24 10:46:14 -0800
commit13e6275e58c3dc84fbb65bc9d05eb875e3096f5f (patch)
tree3c16a8169bf2de80aa13b87a0db099d9b4504216 /lisp/mail/rmail.el
parent5a513470276f1f48ee44f4409a323ba526c18f4e (diff)
downloademacs-13e6275e58c3dc84fbb65bc9d05eb875e3096f5f.tar.gz
fix rmail armor decryption problems
* lisp/mail/rmail.el (rmail-epa-decrypt): Don't decrypt an armor that was copied into the message from a message it is a reply to. (rmail-epa-decrypt-1): Catch and ignore errors in epa-decrypt-region. Make armor-start and armor-end markers.
Diffstat (limited to 'lisp/mail/rmail.el')
-rw-r--r--lisp/mail/rmail.el33
1 files changed, 21 insertions, 12 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 36821e83e0d..7f7f0e967d0 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -4544,6 +4544,9 @@ Argument MIME is non-nil if this is a mime message."
(unless armor-end
(error "Encryption armor beginning has no matching end"))
+ (setq armor-start (move-marker (make-marker) armor-start))
+ (setq armor-end (move-marker (make-marker) armor-end))
+
(goto-char armor-start)
;; Because epa--find-coding-system-for-mime-charset not autoloaded.
@@ -4576,15 +4579,16 @@ Argument MIME is non-nil if this is a mime message."
(mail-unquote-printable-region armor-start
(- (point-max) after-end))))
- ;; Decrypt it, maybe in place, maybe making new buffer.
- (epa-decrypt-region
- armor-start (- (point-max) after-end)
- ;; Call back this function to prepare the output.
- (lambda ()
- (let ((inhibit-read-only t))
- (delete-region armor-start (- (point-max) after-end))
- (goto-char armor-start)
- (current-buffer))))
+ (condition-case nil
+ (epa-decrypt-region
+ armor-start (- (point-max) after-end)
+ ;; Call back this function to prepare the output.
+ (lambda ()
+ (let ((inhibit-read-only t))
+ (delete-region armor-start (- (point-max) after-end))
+ (goto-char armor-start)
+ (current-buffer))))
+ (error nil))
(list armor-start (- (point-max) after-end) mime
armor-end-regexp
@@ -4620,9 +4624,14 @@ Argument MIME is non-nil if this is a mime message."
(goto-char (point-min))
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let ((coding-system-for-read coding-system-for-read)
- (case-fold-search t))
-
- (push (rmail-epa-decrypt-1 mime) decrypts)))
+ (case-fold-search t)
+ (armor-start (match-beginning 0)))
+ ;; Don't decrypt an armor that was copied into
+ ;; the message from a message it is a reply to.
+ (or (equal (buffer-substring (line-beginning-position)
+ armor-start)
+ "> ")
+ (push (rmail-epa-decrypt-1 mime) decrypts))))
(when (and decrypts (eq major-mode 'rmail-mode))
(rmail-add-label "decrypt"))