]> granicus.if.org Git - neomutt/commitdiff
Provide a better prompt and error for inline PGP with attachments. (closes #3738)
authorKevin McCarthy <kevin@8t8.us>
Thu, 3 Dec 2015 23:23:34 +0000 (15:23 -0800)
committerKevin McCarthy <kevin@8t8.us>
Thu, 3 Dec 2015 23:23:34 +0000 (15:23 -0800)
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.

crypt.c

diff --git a/crypt.c b/crypt.c
index 7891c03e46cd911fe873f2644e59cc7da081b4ef..470e1bbd5e997d4bf25ecdc894222816ded49fc6 100644 (file)
--- 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 */
   }