allow non-email in find_keys (grrrr)
authorKrista Bennett <krista@pep-project.org>
Tue, 22 May 2018 09:35:15 +0200
changeset 268152835b311e85
parent 2676 074bceee15b7
child 2682 2880fa61c8d4
allow non-email in find_keys (grrrr)
src/pgp_gpg.c
     1.1 --- a/src/pgp_gpg.c	Fri May 11 09:06:29 2018 +0200
     1.2 +++ b/src/pgp_gpg.c	Tue May 22 09:35:15 2018 +0200
     1.3 @@ -622,11 +622,14 @@
     1.4          }
     1.5          gpgme_error = _GPGERR(gpgme_error);
     1.6          assert(gpgme_error != GPG_ERR_INV_VALUE);
     1.7 -        assert(gpgme_error != GPG_ERR_NO_DATA);
     1.8 +//        assert(gpgme_error != GPG_ERR_NO_DATA);
     1.9  
    1.10          switch (gpgme_error) {
    1.11              case GPG_ERR_NO_ERROR:
    1.12              {
    1.13 +                // EFail: We should get an MDC warning if there were modifications
    1.14 +                //        and never make it here. So the decrypted text is not
    1.15 +                //        returned regardless.
    1.16                  gpgme_decrypt_result = gpg.gpgme_op_decrypt_result(session->ctx);
    1.17                  /* NOW is when we have to process the decrypt_result, period.
    1.18                     it is only valid until the next call on the context. */
    1.19 @@ -853,6 +856,7 @@
    1.20                  break;
    1.21              }
    1.22              case GPG_ERR_BAD_PASSPHRASE:
    1.23 +            case GPG_ERR_NO_DATA:
    1.24                  result = PEP_DECRYPT_NO_KEY;
    1.25                  break;
    1.26              case GPG_ERR_DECRYPT_FAILED:
    1.27 @@ -1826,7 +1830,6 @@
    1.28      return PEP_STATUS_OK;
    1.29  }
    1.30  
    1.31 -
    1.32  static PEP_STATUS _pgp_search_keys(PEP_SESSION session, const char* pattern,
    1.33                              stringlist_t** keylist,
    1.34                              int private_only) {
    1.35 @@ -1871,8 +1874,9 @@
    1.36                  // check that at least one uid's email matches pattern exactly,
    1.37                  // modulo the email-diff heuristic
    1.38                  while(kuid) {
    1.39 -                    if((pattern && kuid->email && _email_heuristic_match(kuid->email, pattern)) ||
    1.40 -                       pattern == NULL /* match all */ )
    1.41 +                    if((pattern == NULL) ||
    1.42 +                       (strstr(pattern, "@") == NULL) || // not an email
    1.43 +                       (kuid->email && _email_heuristic_match(kuid->email, pattern)))
    1.44                      { 
    1.45                          char *fpr = key->subkeys->fpr;
    1.46                          assert(fpr);