diff options
author | Werner Koch <wk@gnupg.org> | 2021-08-20 09:13:01 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2021-08-20 09:18:22 +0200 |
commit | b4345f7521cb4c3f4af7894f5d6d840fda85e82f (patch) | |
tree | efd039f717c3af39c3bd21bd0183e0e3f418405d /common/stringhelp.h | |
parent | scd: Don't release the context until list_finish for PC/SC. (diff) | |
download | gnupg2-b4345f7521cb4c3f4af7894f5d6d840fda85e82f.tar.xz gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'common/stringhelp.h')
-rw-r--r-- | common/stringhelp.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/common/stringhelp.h b/common/stringhelp.h index c5f252bbc..598f698c8 100644 --- a/common/stringhelp.h +++ b/common/stringhelp.h @@ -148,6 +148,9 @@ char **strsplit (char *string, char delim, char replacement, int *count); /* Tokenize STRING using the set of delimiters in DELIM. */ char **strtokenize (const char *string, const char *delim); +/* Tokenize STRING using the set of delimiters in DELIM but do not + * trim the tokens. */ +char **strtokenize_nt (const char *string, const char *delim); /* Split STRING into space delimited fields and store them in the * provided ARRAY. */ |