]> granicus.if.org Git - mutt/commitdiff
Experimental short-cut code if the "image" of an address under a
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 16 Dec 2002 17:59:51 +0000 (17:59 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 16 Dec 2002 17:59:51 +0000 (17:59 +0000)
pgp-hook looks like a hexadecimal key id.

pgp.c

diff --git a/pgp.c b/pgp.c
index 8aa6a0078ed1fa3235b2cce6d98a3e548c0c0c86..7e6ab9d5ca38bd4dc3ca7c7ded505a7f370b76ff 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -1029,6 +1029,20 @@ BODY *pgp_sign_message (BODY *a)
   return (a);
 }
 
+static short is_numerical_keyid (const char *s)
+{
+  /* or should we require the "0x"? */
+  if (strncmp (s, "0x", 2) == 0)
+    s += 2;
+  if (strlen (s) % 8)
+    return 0;
+  while (*s)
+    if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
+      return 0;
+  
+  return 1;
+}
+
 /* This routine attempts to find the keyids of the recipients of a message.
  * It returns NULL if any of the keys can not be found.
  */
@@ -1078,6 +1092,13 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
       snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, p->mailbox);
       if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
       {
+       if (is_numerical_keyid (keyID))
+       {
+         if (strncmp (keyID, "0x", 2) == 0)
+           keyID += 2;
+         goto bypass_selection;                /* you don't see this. */
+       }
+       
        /* check for e-mail address */
        if ((t = strchr (keyID, '@')) && 
            (addr = rfc822_parse_adrlist (NULL, keyID)))
@@ -1118,6 +1139,7 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 
     keyID = pgp_keyid (key);
     
+  bypass_selection:
     keylist_size += mutt_strlen (keyID) + 4;
     safe_realloc ((void **)&keylist, keylist_size);
     sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "",        /* __SPRINTF_CHECKED__ */