Home GnuPG
Diffusion GnuPG 576e429d41a1

wkd: Fix client issue with leading or trailing spaces in user-ids.

Description

wkd: Fix client issue with leading or trailing spaces in user-ids.

* common/recsel.c (recsel_parse_expr): Add flag -t.
* common/stringhelp.c (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>

Details

Provenance
wernerAuthored on Aug 20 2021, 9:13 AM
Parents
rG6685696adafb: gpg: Return SUCCESS/FAILURE status also for --card-edit/name.
Branches
Unknown
Tags
Unknown