aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Schmidt2023-08-15 21:37:08 +0200
committerEli Zaretskii2023-08-17 11:11:01 +0300
commitfac0e2d533427ba7afc2c11427f46acc57fa6be8 (patch)
tree46d7ce32a9c83f15de48554df6af3abbcee0f55a
parent8f683b51d8bc9e8c66608fb6056e0f8765f274f8 (diff)
downloademacs-fac0e2d533427ba7afc2c11427f46acc57fa6be8.tar.gz
emacs-fac0e2d533427ba7afc2c11427f46acc57fa6be8.zip
Avoid false "wrong passphrase" messages in EPA
* lisp/epa-file.el (epa--wrong-password-p): Use a stricter regexp to match "wrong passphrase" errors generated by GnuPG. (Bug#65316)
-rw-r--r--lisp/epa-file.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 4d8ca11e809..a27f241c0c3 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -123,9 +123,16 @@ encryption is used."
123 (cons "Opening input file" (cdr error)))))) 123 (cons "Opening input file" (cdr error))))))
124 124
125(defun epa--wrong-password-p (context) 125(defun epa--wrong-password-p (context)
126 "Return whether a wrong password caused the error in CONTEXT."
126 (let ((error-string (epg-context-error-output context))) 127 (let ((error-string (epg-context-error-output context)))
128 ;; Use a strict regexp here that really only matches "wrong
129 ;; passphrase" errors to avoid hiding diagnostic information
130 ;; (bug#65316). Below regexp also can fail to match non-English
131 ;; messages, since at least the "decryption failed" part of it
132 ;; seems to be localized. But since this means false negatives
133 ;; this is probably OK.
127 (and (string-match 134 (and (string-match
128 "decryption failed: \\(Bad session key\\|No secret key\\)" 135 "decryption failed: \\(Bad session key\\|Bad passphrase\\)"
129 error-string) 136 error-string)
130 (match-string 1 error-string)))) 137 (match-string 1 error-string))))
131 138