summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-04-17 10:04:20 +0200
committerWerner Koch <wk@gnupg.org>2018-04-17 10:04:20 +0200
commit4bba3b8e2c350b8ff0d562ec63cc03a096448d84 (patch)
treeea160533cb38ecbed2cfbf8e8bf936a84c9d263d
parent86efba2be270d2cdd0bc66c9d3fe190495b7af2f (diff)
downloadgpgme-4bba3b8e2c350b8ff0d562ec63cc03a096448d84.tar.gz
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>
-rw-r--r--doc/gpgme.texi12
-rw-r--r--src/engine-gpg.c12
2 files changed, 19 insertions, 5 deletions
diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index 330b167e..3975a971 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -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
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index 90e3b89e..49a1c75e 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -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)