1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-09 21:28:51 +01:00

Allow use of a standard space separated fingerprint.

We allow a single or a double space in the middle of the fingerprint
to help with c+p fingerprints from an HTML pages which are not being
enclosed in a "pre" tag.
* g10/getkey.c (classify_user_id): Check for space separated GPG
fingerprint.
--
This is a backport of commit 957fe72 and 372fb4f.
This commit is contained in:
Werner Koch 2012-01-10 15:32:45 +01:00
parent b9333cd890
commit 9b2a98ea14
2 changed files with 71 additions and 28 deletions

3
NEWS
View File

@ -1,6 +1,9 @@
Noteworthy changes in version 1.4.12 (unreleased)
-------------------------------------------------
* GPG now accepts a space separated fingerprint as a user ID.
This allows to copy and paste the fingerprint from the key
listing.
Noteworthy changes in version 1.4.11 (2010-10-18)

View File

@ -738,15 +738,55 @@ classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc )
}
mode = KEYDB_SEARCH_MODE_FPR20;
}
else {
if (hexprefix) /* This was a hex number with a prefix */
return 0; /* and a wrong length */
else if (!hexprefix) {
/* No hex indicator; check for a space separated
OpenPGP v4 fingerprint like:
8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
or
8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
*/
mode = 0;
hexlength = strspn (s, " 0123456789abcdefABCDEF");
if (s[hexlength] && s[hexlength] != ' ')
hexlength = 0; /* Followed by non-space. */
while (hexlength && s[hexlength-1] == ' ')
hexlength--; /* Trim trailing spaces. */
if ((hexlength == 49 || hexlength == 50)
&& (!s[hexlength] || s[hexlength] == ' ')) {
int i, c;
for (i=0; i < 20; i++) {
if (i && !(i % 2)) {
if (*s != ' ')
break;
s++;
/* Skip the double space in the middle but
don't require it to help copying
fingerprints from sources which fold
multiple space to one. */
if (i == 10 && *s == ' ')
s++;
}
c = hextobyte(s);
if (c == -1)
break;
desc->u.fpr[i] = c;
s += 2;
}
if (i == 20)
mode = KEYDB_SEARCH_MODE_FPR20;
}
if (!mode) {
desc->exact = 0;
desc->u.name = s;
mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */
}
}
else /* This was a hex number with a prefix */
return 0; /* and a wrong length */
}
desc->mode = mode;
return mode;