diff options
author | Werner Koch <wk@gnupg.org> | 2021-04-21 14:31:57 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2021-04-21 14:40:08 +0200 |
commit | f79e9540ca643b5cb912e7bfca2af56be428efed (patch) | |
tree | c42c5982dd893d2846dd3dd85067f6ad8918c7b3 /kbx | |
parent | gpg,sm: Ignore the log-file option from common.conf. (diff) | |
download | gnupg2-f79e9540ca643b5cb912e7bfca2af56be428efed.tar.xz gnupg2-f79e9540ca643b5cb912e7bfca2af56be428efed.zip |
keyboxd: Fix searching for exact mail addresses.
* kbx/kbxserver.c (cmd_search): Use the openpgp hack for calling
classify_user_id.
* kbx/backend-sqlite.c (run_select_statement): Remove angle brackets
in exact addrspec mode.
* g10/call-keyboxd.c (keydb_search): Do not duplicate the left angle
bracket.
* sm/keydb.c (keydb_search): Ditto.
--
Note that the openpgp hack flag of classify_user_id is actually a
misnomer because we actually hack a round a problem in gpgsm. And it
is only over there that we don't set it there. In keyboxd the flag
should be set. And we need to remove the angle brackets of course
because that is how we create the addrspec column values.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'kbx')
-rw-r--r-- | kbx/backend-sqlite.c | 17 | ||||
-rw-r--r-- | kbx/kbxserver.c | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/kbx/backend-sqlite.c b/kbx/backend-sqlite.c index ae2530d1a..202897e91 100644 --- a/kbx/backend-sqlite.c +++ b/kbx/backend-sqlite.c @@ -839,6 +839,8 @@ run_select_statement (ctrl_t ctrl, be_sqlite_local_t ctx, unsigned int descidx; const char *extra = NULL; unsigned char kidbuf[8]; + const char *s; + size_t n; descidx = ctx->descidx; @@ -916,7 +918,20 @@ run_select_statement (ctrl_t ctrl, be_sqlite_local_t ctx, " WHERE p.ubid = u.ubid AND u.addrspec = ?1", extra, " ORDER BY p.ubid", &ctx->select_stmt); if (!err) - err = run_sql_bind_text (ctx->select_stmt, 1, desc[descidx].u.name); + { + s = desc[descidx].u.name; + if (s && *s == '<' && s[1]) + { /* It is common that the indicator for exact addrspec + * search has not been removed. We do this here. */ + s++; + n = strlen (s); + if (n > 1 && s[n-1] == '>') + n--; + } + else + n = s? strlen (s):0; + err = run_sql_bind_ntext (ctx->select_stmt, 1, s, n); + } break; case KEYDB_SEARCH_MODE_MAILSUB: diff --git a/kbx/kbxserver.c b/kbx/kbxserver.c index 8a75035a5..55b478586 100644 --- a/kbx/kbxserver.c +++ b/kbx/kbxserver.c @@ -336,7 +336,7 @@ cmd_search (assuan_context_t ctx, char *line) } else { - err = classify_user_id (line, &ctrl->server_local->search_desc, 0); + err = classify_user_id (line, &ctrl->server_local->search_desc, 1); if (err) goto leave; } |