aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-12-04 13:39:42 +0000
committerWerner Koch <[email protected]>2019-12-04 15:18:36 +0000
commit78bb81e9deeca264f6a516630496470341e78fa9 (patch)
tree28608b65c7770556287d538649592ae0f3ea043e
parentpo: Update Japanese Translation. (diff)
downloadgnupg-78bb81e9deeca264f6a516630496470341e78fa9.tar.gz
gnupg-78bb81e9deeca264f6a516630496470341e78fa9.zip
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 '<[email protected]>' and auto key locate will find the key. Without that a plain mail address; i.e. gpg -e -r '[email protected]' was required. GnuPG-bug-id: 4726 Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--g10/getkey.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 6635b5b54..0aca88ca1 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1025,6 +1025,17 @@ get_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
/* Does NAME appear to be a mailbox (mail address)? */
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 "<[email protected]>" 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
* of methods to look up keys. By default, the local keyring is
@@ -1439,12 +1450,24 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
{
gpg_error_t err;
struct getkey_ctx_s *ctx = NULL;
- int is_mbox = is_valid_mailbox (name);
+ int is_mbox;
int wkd_tried = 0;
if (retctx)
*retctx = NULL;
+ 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 "<[email protected]>" 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:
if (ctx) /* Clear in case of a start over. */
{
@@ -1461,8 +1484,7 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
NULL, include_unusable);
if (err)
{
- getkey_end (ctrl, ctx);
- return err;
+ goto leave;
}
/* If the keyblock was retrieved from the local database and the key
@@ -1588,10 +1610,13 @@ get_best_pubkey_byname (ctrl_t ctrl, enum get_pubkey_modes mode,
}
if (retctx && ctx)
- *retctx = ctx;
- else
- getkey_end (ctrl, ctx);
+ {
+ *retctx = ctx;
+ ctx = NULL;
+ }
+ leave:
+ getkey_end (ctrl, ctx);
return err;
}