gpg: Make the double space in the middle of a fingerprint optional.

This change might help to c+p a fingerprint from an HTML page without
being enclosed in a "pre" tag.
* common/userids.c (classify_user_id): Skip a second blank in the
middle of a fingerprint.
This commit is contained in:
Werner Koch 2012-01-06 15:17:49 +01:00
parent 372fb4fc06
commit 957fe72846
1 changed files with 10 additions and 7 deletions

View File

@ -313,13 +313,16 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
/* Still not found. Now check for a space separated /* Still not found. Now check for a space separated
OpenPGP v4 fingerprint like: OpenPGP v4 fingerprint like:
8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367 8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
or
8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
*/ */
hexlength = strspn (s, " 0123456789abcdefABCDEF"); hexlength = strspn (s, " 0123456789abcdefABCDEF");
if (s[hexlength] && s[hexlength] != ' ') if (s[hexlength] && s[hexlength] != ' ')
hexlength = 0; /* Followed by non-space. */ hexlength = 0; /* Followed by non-space. */
while (hexlength && s[hexlength-1] == ' ') while (hexlength && s[hexlength-1] == ' ')
hexlength--; /* Trim trailing spaces. */ hexlength--; /* Trim trailing spaces. */
if (hexlength == 50 && (!s[hexlength] || s[hexlength] == ' ')) if ((hexlength == 49 || hexlength == 50)
&& (!s[hexlength] || s[hexlength] == ' '))
{ {
int i, c; int i, c;
@ -330,12 +333,12 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
if (*s != ' ') if (*s != ' ')
break; break;
s++; s++;
if (i == 10) /* Skip the double space in the middle but
{ don't require it to help copying
if (*s != ' ') fingerprints from sources which fold
break; multiple space to one. */
s++; if (i == 10 && *s == ' ')
} s++;
} }
c = hextobyte(s); c = hextobyte(s);