mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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>
This commit is contained in:
parent
6685696ada
commit
576e429d41
6 changed files with 201 additions and 20 deletions
|
@ -172,6 +172,8 @@ find_next_lc (char *string)
|
|||
*
|
||||
* -- VALUE spans to the end of the expression.
|
||||
* -c The string match in this part is done case-sensitive.
|
||||
* -t Do not trim leading and trailing spaces from VALUE.
|
||||
* Note that a space after <op> is here required.
|
||||
*
|
||||
* For example four calls to recsel_parse_expr() with these values for
|
||||
* EXPR
|
||||
|
@ -203,6 +205,7 @@ recsel_parse_expr (recsel_expr_t *selector, const char *expression)
|
|||
char *s0, *s;
|
||||
int toend = 0;
|
||||
int xcase = 0;
|
||||
int notrim = 0;
|
||||
int disjun = 0;
|
||||
char *next_lc = NULL;
|
||||
|
||||
|
@ -232,6 +235,7 @@ recsel_parse_expr (recsel_expr_t *selector, const char *expression)
|
|||
{
|
||||
case '-': toend = 1; break;
|
||||
case 'c': xcase = 1; break;
|
||||
case 't': notrim = 1; break;
|
||||
default:
|
||||
log_error ("invalid flag '-%c' in expression\n", *expr);
|
||||
recsel_release (se_head);
|
||||
|
@ -391,8 +395,11 @@ recsel_parse_expr (recsel_expr_t *selector, const char *expression)
|
|||
return my_error (GPG_ERR_INV_OP);
|
||||
}
|
||||
|
||||
while (*s == ' ' || *s == '\t')
|
||||
if (*s == ' ' || *s == '\t')
|
||||
s++;
|
||||
if (!notrim)
|
||||
while (*s == ' ' || *s == '\t')
|
||||
s++;
|
||||
|
||||
if (se->op == SELECT_NONEMPTY || se->op == SELECT_ISTRUE)
|
||||
{
|
||||
|
@ -425,7 +432,8 @@ recsel_parse_expr (recsel_expr_t *selector, const char *expression)
|
|||
return my_error (GPG_ERR_NO_NAME);
|
||||
}
|
||||
|
||||
trim_spaces (se->name + (s - expr));
|
||||
if (!notrim)
|
||||
trim_spaces (se->name + (s - expr));
|
||||
se->value = se->name + (s - expr);
|
||||
if (!se->value[0] && !(se->op == SELECT_NONEMPTY || se->op == SELECT_ISTRUE))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue