Commit 13e6275e authored by Richard Stallman's avatar Richard Stallman Committed by Paul Eggert

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.
parent 5a513470
Pipeline #849 passed with stage
in 54 minutes and 7 seconds
...@@ -4544,6 +4544,9 @@ Argument MIME is non-nil if this is a mime message." ...@@ -4544,6 +4544,9 @@ Argument MIME is non-nil if this is a mime message."
(unless armor-end (unless armor-end
(error "Encryption armor beginning has no matching 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) (goto-char armor-start)
;; Because epa--find-coding-system-for-mime-charset not autoloaded. ;; Because epa--find-coding-system-for-mime-charset not autoloaded.
...@@ -4576,7 +4579,7 @@ Argument MIME is non-nil if this is a mime message." ...@@ -4576,7 +4579,7 @@ Argument MIME is non-nil if this is a mime message."
(mail-unquote-printable-region armor-start (mail-unquote-printable-region armor-start
(- (point-max) after-end)))) (- (point-max) after-end))))
;; Decrypt it, maybe in place, maybe making new buffer. (condition-case nil
(epa-decrypt-region (epa-decrypt-region
armor-start (- (point-max) after-end) armor-start (- (point-max) after-end)
;; Call back this function to prepare the output. ;; Call back this function to prepare the output.
...@@ -4585,6 +4588,7 @@ Argument MIME is non-nil if this is a mime message." ...@@ -4585,6 +4588,7 @@ Argument MIME is non-nil if this is a mime message."
(delete-region armor-start (- (point-max) after-end)) (delete-region armor-start (- (point-max) after-end))
(goto-char armor-start) (goto-char armor-start)
(current-buffer)))) (current-buffer))))
(error nil))
(list armor-start (- (point-max) after-end) mime (list armor-start (- (point-max) after-end) mime
armor-end-regexp armor-end-regexp
...@@ -4620,9 +4624,14 @@ Argument MIME is non-nil if this is a mime message." ...@@ -4620,9 +4624,14 @@ Argument MIME is non-nil if this is a mime message."
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let ((coding-system-for-read coding-system-for-read) (let ((coding-system-for-read coding-system-for-read)
(case-fold-search t)) (case-fold-search t)
(armor-start (match-beginning 0)))
(push (rmail-epa-decrypt-1 mime) decrypts))) ;; 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)) (when (and decrypts (eq major-mode 'rmail-mode))
(rmail-add-label "decrypt")) (rmail-add-label "decrypt"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment