]> granicus.if.org Git - mutt/commitdiff
Show top-level decoded smime text/plain parts.
authorKevin McCarthy <kevin@8t8.us>
Fri, 25 Jan 2019 02:28:27 +0000 (18:28 -0800)
committerKevin McCarthy <kevin@8t8.us>
Fri, 25 Jan 2019 02:41:36 +0000 (18:41 -0800)
Commit 331d9d5a attempted to fix a problem with an attachment having
extension .p7m.  The attachment menu tried to decode and failed, and
the part ended up being replaced by a bogus text/plain part.

The problem is that crypt_smime_decrypt_mime() returns a text/plain
part if the decode fails, meaning we can't distinguish failure from
success in this case.

As a compromise, only use a text/plain resulting from a single
top-level application_smime part.  This will allow for the case of an
text/plain encoded email, but won't end up hiding attachments that
were not decoded.

recvattach.c

index 1bd4b48efc60cd677a7cda61a9ee272a45ca1ad7..b4c77676bcb77a9da74b13529f3f0dc8f8d0a0d3 100644 (file)
@@ -926,18 +926,19 @@ mutt_attach_display_loop (MUTTMENU *menu, int op, HEADER *hdr,
 
 static void mutt_generate_recvattach_list (ATTACH_CONTEXT *actx,
                                            HEADER *hdr,
-                                           BODY *m,
+                                           BODY *parts,
                                            FILE *fp,
                                            int parent_type,
                                            int level,
                                            int decrypted)
 {
   ATTACHPTR *new;
+  BODY *m;
   BODY *new_body = NULL;
   FILE *new_fp = NULL;
   int type, need_secured, secured;
 
-  for (; m; m = m->next)
+  for (m = parts; m; m = m->next)
   {
     need_secured = secured = 0;
 
@@ -957,11 +958,14 @@ static void mutt_generate_recvattach_list (ATTACH_CONTEXT *actx,
 
       secured = !crypt_smime_decrypt_mime (fp, &new_fp, m, &new_body);
       /* If the decrypt/verify-opaque doesn't generate mime output, an
-       * empty "TEXT" type will still be returned by
-       * mutt_read_mime_header().  Since recursing over that type
-       * isn't interesting and loses information about the original
-       * attachment, just abort and view normally. */
-      if (secured && new_body->type == TYPETEXT)
+       * empty text/plain type will still be returned by
+       * mutt_read_mime_header().  We can't distinguish an actual part
+       * from a failure, so only use a text/plain that results from a single
+       * top-level part. */
+      if (secured &&
+          new_body->type == TYPETEXT &&
+          !ascii_strcasecmp ("plain", new_body->subtype) &&
+          (parts != m || m->next))
       {
         mutt_free_body (&new_body);
         safe_fclose (&new_fp);