From 2264b64b85e6d522fdc5e06d5260f5b7b5414417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 4 Sep 2024 14:31:12 +0200 Subject: core: Treat email-only user IDs with upper case letters as email address * src/key.c (_gpgme_key_append_name): Support email-only user IDs with upper case letters. * tests/gpg/t-keylist.c (struct key_info_s): Add algo, length, sec_algo, sec_length. (keys): Add expected algo and length for primary and secondary subkeys. (main): Factor out code for checking a key and the code for the keylist test. Call the factored out test function and a new test function. (check_key, test_keylist, key_with_email_only_user_id, key_info_email_only_user_id, test_email_only_user_id_with_upper_case_letters): New. -- Email-only user IDs with upper case letters are now also parsed as a user ID with empty name and the complete user ID as email. GnuPG-bug-id: 7280 --- src/key.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/key.c b/src/key.c index fec9eb16..77651d31 100644 --- a/src/key.c +++ b/src/key.c @@ -237,12 +237,24 @@ _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert) uid->address = _gpgme_mailbox_from_userid (uid->uid); if ((!uid->email || !*uid->email) && uid->address && uid->name - && !strcmp (uid->name, uid->address)) + && !strcasecmp (uid->name, uid->address)) { - /* Name and address are the same. This is a mailbox only key. - Use address as email and remove name. */ - *uid->name = '\0'; - uid->email = uid->address; + /* Name and address are the same except that some letters may have + different case. This is a mailbox only key. */ + if (!strcmp (uid->name, uid->address)) + { + /* Name and address are the identical. Use address as email + and remove name. */ + *uid->name = '\0'; + uid->email = uid->address; + } + else + { + /* Name and address are the same except for different case of + some letters. Use name as email and point name to EOS. */ + uid->email = uid->name; + uid->name = (dst - 1); + } } if (!key->uids) -- cgit v1.2.3