aboutsummaryrefslogtreecommitdiffstats
path: root/tools/wks-util.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-08-20 07:13:01 +0000
committerWerner Koch <[email protected]>2021-08-20 07:18:22 +0000
commitb4345f7521cb4c3f4af7894f5d6d840fda85e82f (patch)
treeefd039f717c3af39c3bd21bd0183e0e3f418405d /tools/wks-util.c
parentscd: Don't release the context until list_finish for PC/SC. (diff)
downloadgnupg-b4345f7521cb4c3f4af7894f5d6d840fda85e82f.tar.gz
gnupg-b4345f7521cb4c3f4af7894f5d6d840fda85e82f.zip
wkd: Fix client issue with leading or trailing spaces in user-ids.
* common/recsel.c (recsel_parse_expr): Add flag -t. * common/stringhelp.c: Remove assert.h. (strtokenize): Factor code out to do_strtokenize. (strtokenize_nt): New. (do_strtokenize): Add arg trim to support the strtokenize_nt. * common/t-stringhelp.c (test_strtokenize_nt): New test cases. * tools/wks-util.c (wks_list_key): Use strtokenize_nt and the recsel flag -t. -- This fixes a bug with user ids with leading spaces because: wks-client lists all mail addresses from the key and matches them to the requested mail address. If there are several user-ids all with the same mail address wks-client picks one of them and then extracts exactly that user id. However, here it does not match by the mail address but by the full user-id so that we can be sure that there will be only one user-id in the final key. The filter built expression unfortunately strips leading blanks but requires a verbatim match. Thus it won't find the user id again and errors out. The new -t flag and a non-trimming strtokenize solves the problem. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/wks-util.c')
-rw-r--r--tools/wks-util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/wks-util.c b/tools/wks-util.c
index 516c7fe00..b9512ba1b 100644
--- a/tools/wks-util.c
+++ b/tools/wks-util.c
@@ -348,7 +348,7 @@ wks_list_key (estream_t key, char **r_fpr, uidinfo_list_t *r_mboxes)
/* log_debug ("line '%s'\n", line); */
xfree (fields);
- fields = strtokenize (line, ":");
+ fields = strtokenize_nt (line, ":");
if (!fields)
{
err = gpg_error_from_syserror ();
@@ -467,7 +467,7 @@ wks_filter_uid (estream_t *r_newkey, estream_t key, const char *uid,
es_fputs ("Content-Type: application/pgp-keys\n"
"\n", newkey);
- filterexp = es_bsprintf ("keep-uid=uid= %s", uid);
+ filterexp = es_bsprintf ("keep-uid=-t uid= %s", uid);
if (!filterexp)
{
err = gpg_error_from_syserror ();