mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-07 17:33:02 +01:00
gpg: Use AKL for angle bracketed mail address with -r.
* g10/getkey.c (get_pubkey_byname): Extend is_mbox checking. (get_best_pubkey_byname): Ditto. -- With this patch it is now possible to use gpg -e -r '<foo@example.org>' and auto key locate will find the key. Without that a plain mail address; i.e. gpg -e -r 'foo@example.org' was required. GnuPG-bug-id: 4726 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d2ff62dbdf
commit
1abb39fdaf
37
g10/getkey.c
37
g10/getkey.c
@ -928,6 +928,17 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||||||
|
|
||||||
/* Does NAME appear to be a mailbox (mail address)? */
|
/* Does NAME appear to be a mailbox (mail address)? */
|
||||||
is_mbox = is_valid_mailbox (name);
|
is_mbox = is_valid_mailbox (name);
|
||||||
|
if (!is_mbox && *name == '<' && name[1] && name[strlen(name)-1]=='>'
|
||||||
|
&& name[1] != '>'
|
||||||
|
&& is_valid_mailbox_mem (name+1, strlen (name)-2))
|
||||||
|
{
|
||||||
|
/* The mailbox is in the form "<foo@example.org>" which is not
|
||||||
|
* detected by is_valid_mailbox. Set the flag but keep name as
|
||||||
|
* it is because the bracketed name is actual the better
|
||||||
|
* specification for a local search and the other methods
|
||||||
|
* extract the mail address anyway. */
|
||||||
|
is_mbox = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* The auto-key-locate feature works as follows: there are a number
|
/* The auto-key-locate feature works as follows: there are a number
|
||||||
* of methods to look up keys. By default, the local keyring is
|
* of methods to look up keys. By default, the local keyring is
|
||||||
@ -1359,7 +1370,7 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
struct getkey_ctx_s *ctx = NULL;
|
struct getkey_ctx_s *ctx = NULL;
|
||||||
int is_mbox = is_valid_mailbox (name);
|
int is_mbox;
|
||||||
int wkd_tried = 0;
|
int wkd_tried = 0;
|
||||||
PKT_public_key pk0;
|
PKT_public_key pk0;
|
||||||
|
|
||||||
@ -1371,6 +1382,18 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||||||
memset (&pk0, 0, sizeof pk0);
|
memset (&pk0, 0, sizeof pk0);
|
||||||
pk0.req_usage = pk? pk->req_usage : 0;
|
pk0.req_usage = pk? pk->req_usage : 0;
|
||||||
|
|
||||||
|
is_mbox = is_valid_mailbox (name);
|
||||||
|
if (!is_mbox && *name == '<' && name[1] && name[strlen(name)-1]=='>'
|
||||||
|
&& name[1] != '>'
|
||||||
|
&& is_valid_mailbox_mem (name+1, strlen (name)-2))
|
||||||
|
{
|
||||||
|
/* The mailbox is in the form "<foo@example.org>" which is not
|
||||||
|
* detected by is_valid_mailbox. Set the flag but keep name as
|
||||||
|
* it is because get_pubkey_byname does an is_valid_mailbox_mem
|
||||||
|
* itself. */
|
||||||
|
is_mbox = 1;
|
||||||
|
}
|
||||||
|
|
||||||
start_over:
|
start_over:
|
||||||
if (ctx) /* Clear in case of a start over. */
|
if (ctx) /* Clear in case of a start over. */
|
||||||
{
|
{
|
||||||
@ -1384,8 +1407,7 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||||||
NULL, include_unusable);
|
NULL, include_unusable);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
getkey_end (ctrl, ctx);
|
goto leave;
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the keyblock was retrieved from the local database and the key
|
/* If the keyblock was retrieved from the local database and the key
|
||||||
@ -1530,10 +1552,13 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (retctx && ctx)
|
if (retctx && ctx)
|
||||||
*retctx = ctx;
|
{
|
||||||
else
|
*retctx = ctx;
|
||||||
getkey_end (ctrl, ctx);
|
ctx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
leave:
|
||||||
|
getkey_end (ctrl, ctx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user