core: Allow for --hidden keyword in OpenPGP recpstrings.

* src/engine-gpg.c (append_args_from_recipients_string): Add special
keywords.
--

GnuPG-bug-id: 3775
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-04-17 10:04:20 +02:00
parent 86efba2be2
commit 4bba3b8e2c
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 19 additions and 5 deletions

View File

@ -6180,8 +6180,16 @@ This is an extended version of @code{gpgme_op_encrypt} with
@var{recpstring} is not NULL, the latter is expected to be a linefeed
delimited string with the set of key specifications. In contrast to
@var{recp} the keys are given directly as strings and there is no need
to first create key objects. The keys are passed verbatim to the
backend engine.
to first create key objects. Leading and trailing white space is
remove from each line in @var{recpstring}. The keys are then passed
verbatim to the backend engine.
For the OpenPGP backend two special keywords are supported to modify
the operation: If the keyword "--hidden" is given as a recipient, it
is skipped but will trun all following key specifications to be hidden
recipients. If the keyword "--" is given as a recipient, it will be
skipped but no keywords will be detected in all following key
specifications.
@end deftypefun

View File

@ -1985,6 +1985,8 @@ append_args_from_recipients_string (engine_gpg_t gpg,
{
gpg_error_t err = 0;
int any = 0;
int ignore = 0;
int hidden = 0;
const char *s;
int n;
@ -2005,10 +2007,14 @@ append_args_from_recipients_string (engine_gpg_t gpg,
while (n && (string[n-1] == ' ' || string[n-1] == '\t'))
n--;
/* Add arg if it is not empty. */
if (n)
if (!ignore && n == 2 && !memcmp (string, "--", 2))
ignore = 1;
else if (!ignore && n == 8 && !memcmp (string, "--hidden", 8))
hidden = 1;
else if (n)
{
err = add_arg (gpg, "-r");
/* Add arg if it is not empty. */
err = add_arg (gpg, hidden? "-R":"-r");
if (!err)
err = add_arg_recipient_string (gpg, flags, string, n);
if (!err)