From: Thomas Roessler Date: Mon, 16 Dec 2002 17:59:51 +0000 (+0000) Subject: Experimental short-cut code if the "image" of an address under a X-Git-Tag: mutt-1-5-3-rel~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=769ecee7c416e91695b5cc5b85df185cf63838a3;p=mutt Experimental short-cut code if the "image" of an address under a pgp-hook looks like a hexadecimal key id. --- diff --git a/pgp.c b/pgp.c index 8aa6a007..7e6ab9d5 100644 --- 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__ */