From: Kevin McCarthy Date: Thu, 3 Dec 2015 23:23:34 +0000 (-0800) Subject: Provide a better prompt and error for inline PGP with attachments. (closes #3738) X-Git-Tag: neomutt-20160404~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0640d21f3255b0bb9bfc14b1895ee1e7bb255f5;p=neomutt Provide a better prompt and error for inline PGP with attachments. (closes #3738) Change mutt_protect() to check for text/plain before trying to invoke crypt_pgp_traditional_encryptsign(). This way, mutt can provide a bit more specific prompt and error message. Since pgp_mime_auto says it will prompt in the event of any failure, keep the more generic prompt after the encryptsign call too. --- diff --git a/crypt.c b/crypt.c index 7891c03e4..470e1bbd5 100644 --- a/crypt.c +++ b/crypt.c @@ -142,21 +142,34 @@ int mutt_protect (HEADER *msg, char *keylist) if ((WithCrypto & APPLICATION_PGP) && ((msg->security & PGPINLINE) == PGPINLINE)) { - /* they really want to send it inline... go for it */ - if (!isendwin ()) mutt_endwin _("Invoking PGP..."); - pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist); - if (pbody) + if ((msg->content->type != TYPETEXT) || + ascii_strcasecmp (msg->content->subtype, "plain")) { - msg->content = pbody; - return 0; + if ((i = query_quadoption (OPT_PGPMIMEAUTO, + _("Inline PGP can't be used with attachments. Revert to PGP/MIME?"))) != M_YES) + { + mutt_error _("Mail not sent: inline PGP can't be used with attachments."); + return -1; + } } + else + { + /* they really want to send it inline... go for it */ + if (!isendwin ()) mutt_endwin _("Invoking PGP..."); + pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist); + if (pbody) + { + msg->content = pbody; + return 0; + } - /* otherwise inline won't work...ask for revert */ - if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?"))) != M_YES) + /* otherwise inline won't work...ask for revert */ + if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?"))) != M_YES) { - mutt_error _("Mail not sent."); - return -1; + mutt_error _("Mail not sent."); + return -1; } + } /* go ahead with PGP/MIME */ }