1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Lowercase mailbox for PKA lookups.

* common/stringhelp.c (ascii_strlwr): New.
* common/mbox-util.c (mailbox_from_userid): Downcase result.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-02-26 18:16:45 +01:00
parent 736710aede
commit c071be698e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 17 additions and 3 deletions

View File

@ -124,8 +124,9 @@ is_valid_mailbox (const char *name)
/* Return the mailbox (local-part@domain) form a standard user id.
Caller must free the result. Returns NULL if no valid mailbox was
found (or we are out of memory). */
All plain ASCII characters in the result are converted to
lowercase. Caller must free the result. Returns NULL if no valid
mailbox was found (or we are out of memory). */
char *
mailbox_from_userid (const char *userid)
{
@ -176,7 +177,7 @@ mailbox_from_userid (const char *userid)
else
errno = EINVAL;
return result;
return result? ascii_strlwr (result): NULL;
}

View File

@ -804,6 +804,18 @@ ascii_tolower (int c)
return c;
}
/* Lowercase all ASCII characters in S. */
char *
ascii_strlwr (char *s)
{
char *p = s;
for (p=s; *p; p++ )
if (isascii (*p) && *p >= 'A' && *p <= 'Z')
*p |= 0x20;
return s;
}
int
ascii_strcasecmp( const char *a, const char *b )

View File

@ -75,6 +75,7 @@ int ascii_isupper (int c);
int ascii_islower (int c);
int ascii_toupper (int c);
int ascii_tolower (int c);
char *ascii_strlwr (char *s);
int ascii_strcasecmp( const char *a, const char *b );
int ascii_strncasecmp (const char *a, const char *b, size_t n);
int ascii_memcasecmp( const void *a, const void *b, size_t n );