Commit 5d8b92c6 authored by Matthew Barnes's avatar Matthew Barnes

CamelGpgContext: Enclose email addresses in brackets.

The recipient list for encrypting can be specified by either key ID or
email address.  Enclose email addresses in brackets to ensure an exact
match, as per the gpg man page:

HOW TO SPECIFY A USER ID

       ...

       By exact match on an email address.
              This is indicated by enclosing the email address in the
              usual way with left and right angles.

         <heinrichh@uni-duesseldorf.de>

Without the brackets gpg uses a substring match, which risks selecting
the wrong recipient.
parent 3e789c94
......@@ -311,13 +311,25 @@ static void
gpg_ctx_add_recipient (struct _GpgCtx *gpg,
const gchar *keyid)
{
gchar *safe_keyid;
if (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)
return;
if (!gpg->recipients)
gpg->recipients = g_ptr_array_new ();
g_ptr_array_add (gpg->recipients, g_strdup (keyid));
g_return_if_fail (keyid != NULL);
/* If the recipient looks like an email address,
* enclose it in brackets to ensure an exact match. */
if (strchr (keyid, '@') != NULL) {
safe_keyid = g_strdup_printf ("<%s>", keyid);
} else {
safe_keyid = g_strdup (keyid);
}
g_ptr_array_add (gpg->recipients, safe_keyid);
}
static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment