]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch show: Include output for the enclosing multipart part of a MIME mail
authorCarl Worth <cworth@cworth.org>
Tue, 17 May 2011 05:28:36 +0000 (22:28 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 17 May 2011 21:51:06 +0000 (14:51 -0700)
Previously, the outer multipart part of any multipart/mixed,
multipart/signed, etc. MIME message was silently omitted from the
"notmuch show" output. This prevented any client from correctly
determining to which parts a signature applies, for example.

Now, we actually emit these parts as their own parts. The output is
still flattened---the contained parts are not yet included "within"
the multipart part---so it's still not possible to determine to which
parts a signature applies, but this is one step along the path.

The test suite is updated to reflect this change, (though we'll
eventually want to fix the emacs interface to not display buttons for
the multipart enclosure parts as there's nothing useful for the user
to actually do with them).

notmuch-show.c
show-message.c
test/emacs.expected-output/notmuch-show-thread-maildir-storage
test/multipart

index ef421ec7cc382ea6e3dbe188c50d1140423b6f30..c8771520922dc5521523ec8209f9410b97589dc3 100644 (file)
@@ -410,6 +410,11 @@ format_part_text (GMimeObject *part, int *part_count)
        show_part_content (part, stream_stdout);
        g_object_unref(stream_stdout);
     }
+    else if (g_mime_content_type_is_type (content_type, "multipart", "*"))
+    {
+       /* Do nothing for multipart since its content will be printed
+        * when recursing. */
+    }
     else
     {
        printf ("Non-text part: %s\n",
index b1b61be40c2618fddcc56c46e683e517f9101f7d..ff9146e233124b81a110481b58ff4e76a57525a5 100644 (file)
@@ -30,6 +30,9 @@ show_message_part (GMimeObject *part, int *part_count,
        GMimeMultipart *multipart = GMIME_MULTIPART (part);
        int i;
 
+       *part_count = *part_count + 1;
+       (*show_part) (part, part_count);
+
        for (i = 0; i < g_mime_multipart_get_count (multipart); i++) {
            show_message_part (g_mime_multipart_get_part (multipart, i),
                               part_count, show_part);
index 086f87403800bdded9a158a20ded7ca889ae2d6b..6eed85b850555a604f021830051557debb0934a0 100644 (file)
@@ -3,6 +3,9 @@ Subject: [notmuch] Working with Maildir storage?
 To: notmuch@notmuchmail.org
 Date: Tue, 17 Nov 2009 14:00:54 -0500
 
+[ multipart/mixed ]
+[ multipart/signed ]
+[ text/plain ]
 I saw the LWN article and decided to take a look at notmuch.  I'm
 currently using mutt and mairix to index and read a collection of
 Maildir mail folders (around 40,000 messages total).
@@ -41,6 +44,9 @@ http://notmuchmail.org/mailman/listinfo/notmuch
  To: notmuch@notmuchmail.org
  Date: Wed, 18 Nov 2009 01:02:38 +0600
 
+ [ multipart/mixed ]
+ [ multipart/signed ]
+ [ text/plain ]
 
  Twas brillig at 14:00:54 17.11.2009 UTC-05 when lars@seas.harvard.edu did gyre and gimble:
 
@@ -68,6 +74,9 @@ http://notmuchmail.org/mailman/listinfo/notmuch
   Cc: notmuch@notmuchmail.org
   Date: Tue, 17 Nov 2009 15:33:01 -0500
 
+  [ multipart/mixed ]
+  [ multipart/signed ]
+  [ text/plain ]
   > See the patch just posted here.
 
   Is the list archived anywhere?  The obvious archives
@@ -148,6 +157,9 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Cc: notmuch@notmuchmail.org
     Date: Tue, 17 Nov 2009 19:50:40 -0500
 
+    [ multipart/mixed ]
+    [ multipart/signed ]
+    [ text/plain ]
     > I've also pushed a slightly more complicated (and complete) fix to my
     > private notmuch repository
 
index dde25abc2fa7c0b0e6b175178b4e740a4a979c50..ef9a8a2ec2b9bba8cc581c7fa563f091134d038f 100755 (executable)
@@ -58,19 +58,23 @@ To: cworth@cworth.org
 Date: Tue, 05 Jan 2001 15:43:57 -0000
 \fheader}
 \fbody{
-\fpart{ ID: 1, Content-type: text/plain
+\fpart{ ID: 1, Content-type: multipart/signed
+\fpart}
+\fpart{ ID: 2, Content-type: multipart/mixed
+\fpart}
+\fpart{ ID: 3, Content-type: text/plain
 This is an inline text part.
 \fpart}
-\fattachment{ ID: 2, Content-type: text/plain
+\fattachment{ ID: 4, Content-type: text/plain
 Attachment: attachment (text/plain)
 This is a text attachment.
 \fattachment}
-\fpart{ ID: 3, Content-type: text/plain
+\fpart{ ID: 5, Content-type: text/plain
 And this message is signed.
 
 -Carl
 \fpart}
-\fpart{ ID: 4, Content-type: application/pgp-signature
+\fpart{ ID: 6, Content-type: application/pgp-signature
 Non-text part: application/pgp-signature
 \fpart}
 \fbody}
@@ -78,7 +82,7 @@ Non-text part: application/pgp-signature
 
 test_begin_subtest "Show multipart MIME message (--format=json)"
 output=$(notmuch show --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org')
-test_expect_equal "$output" '[[[{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "/home/cworth/src/notmuch/test/tmp.multipart/mail/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Tue, 05 Jan 2001 15:43:57 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "This is an inline text part.\n"}, {"id": 2, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 3, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}, {"id": 4, "content-type": "application/pgp-signature"}]}, []]]]'
+test_expect_equal "$output" '[[[{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "/home/cworth/src/notmuch/test/tmp.multipart/mail/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Tue, 05 Jan 2001 15:43:57 -0000"}, "body": [{"id": 1, "content-type": "multipart/signed"}, {"id": 2, "content-type": "multipart/mixed"}, {"id": 3, "content-type": "text/plain", "content": "This is an inline text part.\n"}, {"id": 4, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 5, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}, {"id": 6, "content-type": "application/pgp-signature"}]}, []]]]'
 
 test_done