gpg: Make the double space in the middle of a fingerprint optional.
authorWerner Koch <wk@gnupg.org>
Fri, 6 Jan 2012 14:17:49 +0000 (15:17 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 6 Jan 2012 14:17:49 +0000 (15:17 +0100)
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.

common/userids.c

index 2b13445..88593bf 100644 (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
                  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
                */
               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 == 50 && (!s[hexlength] || s[hexlength] == ' '))
+              if ((hexlength == 49 || hexlength == 50)
+                  && (!s[hexlength] || s[hexlength] == ' '))
                 {
                   int i, c;
 
@@ -330,12 +333,12 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
                           if (*s != ' ')
                             break;
                           s++;
-                          if (i == 10)
-                            {
-                              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);