]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix two mml-sec minor bugs revealed by new test harness
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 Aug 2020 17:26:04 +0000 (19:26 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 Aug 2020 17:28:51 +0000 (19:28 +0200)
* lisp/gnus/mml-sec.el
(mml-secure-allow-signing-with-unknown-recipient): New variable
(bug#18393) (but this should probably be fixed in a different way).
(mml-secure-epg-sign): Use it.
(mml-secure-check-user-id): Protect against recipients that aren't
email addresses, like "No recipient".

lisp/gnus/mml-sec.el

index 740e1d2b7227f5e62f4fc83da4d378d3c95166bc..69852c381d6bf0c839fc9767da808375d47c4a88 100644 (file)
@@ -665,8 +665,9 @@ The passphrase is read and cached."
                         (epg-user-id-string uid))))
                 (equal (downcase (car (mail-header-parse-address
                                        (epg-user-id-string uid))))
-                       (downcase (car (mail-header-parse-address
-                                       recipient))))
+                       (downcase (or (car (mail-header-parse-address
+                                           recipient))
+                                     recipient)))
                 (not (memq (epg-user-id-validity uid)
                            '(revoked expired))))
            (throw 'break t))))))
@@ -937,6 +938,10 @@ If no one is selected, symmetric encryption will be performed.  "
        (signal (car error) (cdr error))))
     cipher))
 
+;; Should probably be removed and the interface should be different.
+(defvar mml-secure-allow-signing-with-unknown-recipient nil
+  "Variable to bind to allow automatic recipient selection.")
+
 (defun mml-secure-epg-sign (protocol mode)
   ;; Based on code appearing inside mml2015-epg-sign.
   (let* ((context (epg-make-context protocol))
@@ -953,7 +958,8 @@ If no one is selected, symmetric encryption will be performed.  "
         ;; then there's no point advising the user to examine it.  If
         ;; there are any other variables worth examining, please
         ;; improve this error message by having it mention them.
-        (error "Couldn't find any signer names%s" maybe-msg)))
+       (unless mml-secure-allow-signing-with-unknown-recipient
+          (error "Couldn't find any signer names%s" maybe-msg))))
     (when (eq 'OpenPGP protocol)
       (setf (epg-context-armor context) t)
       (setf (epg-context-textmode context) t)