diff --git a/src/mu-msg-file.c b/src/mu-msg-file.c index 2c97e85e..298ced54 100644 --- a/src/mu-msg-file.c +++ b/src/mu-msg-file.c @@ -624,10 +624,11 @@ get_body (MuMsgFile *self, gboolean want_html) } -G_GNUC_UNUSED static void +static void append_text (GMimeObject *parent, GMimeObject *part, gchar **txt) { GMimeContentType *ct; + GMimeContentDisposition *disp; gchar *parttxt, *tmp; gboolean err; @@ -635,14 +636,15 @@ append_text (GMimeObject *parent, GMimeObject *part, gchar **txt) return; ct = g_mime_object_get_content_type (part); - if (!GMIME_IS_CONTENT_TYPE(ct)) { - g_warning ("%s: no content-type for part", __FUNCTION__); - return; - } + if (!GMIME_IS_CONTENT_TYPE(ct) || + !g_mime_content_type_is_type (ct, "text", "plain")) + return; /* not a text-plain part */ - /* is it right content type? */ - if (!g_mime_content_type_is_type (ct, "text", "plain")) - return; /* nope */ + disp = g_mime_object_get_content_disposition (part); + if (GMIME_IS_CONTENT_DISPOSITION(disp) && + g_strcmp0 (g_mime_content_disposition_get_disposition (disp), + GMIME_DISPOSITION_ATTACHMENT) == 0) + return; /* it's an attachment, don't include */ parttxt = mu_msg_mime_part_to_string (GMIME_PART(part), &err); if (err) { @@ -651,8 +653,7 @@ append_text (GMimeObject *parent, GMimeObject *part, gchar **txt) return; } - /* it's a text part -- append it! note, we ignore the - * disposition here. */ + /* it's a text part -- append it! */ tmp = *txt; if (*txt) { *txt = g_strconcat (*txt, parttxt, NULL); @@ -666,7 +667,7 @@ append_text (GMimeObject *parent, GMimeObject *part, gchar **txt) /* instead of just the body, this function returns a concatenation of * all text/plain parts with inline disposition */ -G_GNUC_UNUSED static char* +static char* get_concatenated_text (MuMsgFile *self) { char *txt; @@ -795,7 +796,7 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid, return get_recipient (self, recipient_type(mfid)); case MU_MSG_FIELD_ID_BODY_TEXT: *do_free = TRUE; - return get_body (self, FALSE); + return get_concatenated_text (self); case MU_MSG_FIELD_ID_BODY_HTML: *do_free = TRUE; return get_body (self, TRUE); diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index e3392f27..c2de2022 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -129,6 +129,7 @@ EXTRA_DIST= \ testdir/cur/signed!2,S \ testdir/cur/encrypted!2,S \ testdir/cur/signed-encrypted!2,S \ + testdir/cur/multimime!2,FS \ testdir2/bar/cur/mail1 \ testdir2/bar/cur/mail2 \ testdir2/bar/cur/mail3 \ diff --git a/src/tests/test-mu-maildir.c b/src/tests/test-mu-maildir.c index d4bc64d8..bb187470 100644 --- a/src/tests/test-mu-maildir.c +++ b/src/tests/test-mu-maildir.c @@ -259,7 +259,7 @@ test_mu_maildir_walk_01 (void) &data); g_assert_cmpuint (MU_OK, ==, rv); - g_assert_cmpuint (data._file_count, ==, 16); + g_assert_cmpuint (data._file_count, ==, 17); g_assert_cmpuint (data._dir_entered,==, 5); g_assert_cmpuint (data._dir_left,==, 5); @@ -297,7 +297,7 @@ test_mu_maildir_walk_02 (void) &data); g_assert_cmpuint (MU_OK, ==, rv); - g_assert_cmpuint (data._file_count, ==, 12); + g_assert_cmpuint (data._file_count, ==, 13); g_assert_cmpuint (data._dir_entered,==, 4); g_assert_cmpuint (data._dir_left,==, 4); diff --git a/src/tests/test-mu-msg.c b/src/tests/test-mu-msg.c index ea48680d..2b7129cb 100644 --- a/src/tests/test-mu-msg.c +++ b/src/tests/test-mu-msg.c @@ -217,6 +217,24 @@ test_mu_msg_04 (void) } +static void +test_mu_msg_multimime (void) +{ + MuMsg *msg; + + msg = mu_msg_new_from_file + (MU_TESTMAILDIR "/cur/multimime!2,FS", NULL, NULL); + /* ie., are text parts properly concatenated? */ + g_assert_cmpstr (mu_msg_get_subject(msg), + ==, "multimime"); + g_assert_cmpstr (mu_msg_get_body_text(msg), + ==, "abcdef"); + + mu_msg_unref (msg); +} + + + static void test_mu_msg_umlaut (void) { @@ -395,6 +413,8 @@ main (int argc, char *argv[]) test_mu_msg_03); g_test_add_func ("/mu-msg/mu-msg-04", test_mu_msg_04); + g_test_add_func ("/mu-msg/mu-msg-multimime", + test_mu_msg_multimime); g_test_add_func ("/mu-msg/mu-msg-tags", test_mu_msg_tags); g_test_add_func ("/mu-msg/mu-msg-references", diff --git a/src/tests/test-mu-query.c b/src/tests/test-mu-query.c index 48a39a26..6bdb0fd8 100644 --- a/src/tests/test-mu-query.c +++ b/src/tests/test-mu-query.c @@ -160,7 +160,7 @@ test_mu_query_01 (void) { "foo:pepernoot", 0 }, { "funky", 1 }, { "fünkÿ", 1 }, - { "", 16 } + { "", 17 } }; xpath = fill_database (MU_TESTMAILDIR); @@ -214,6 +214,7 @@ test_mu_query_03 (void) { "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1}, { "to:help-gnu-emacs@gnu.org", 4}, { "t:help-gnu-emacs", 0}, + { "flag:flagged", 1} }; xpath = fill_database (MU_TESTMAILDIR); @@ -243,9 +244,9 @@ test_mu_query_04 (void) { "baggins", 1}, { "prio:h", 1}, { "prio:high", 1}, - { "prio:normal", 8}, + { "prio:normal", 9}, { "prio:l", 7}, - { "not prio:l", 9}, + { "not prio:l", 10}, }; xpath = fill_database (MU_TESTMAILDIR); @@ -394,11 +395,11 @@ test_mu_query_dates_helsinki (void) /* { "date:20080804..20080731", 5}, */ { "date:20080731..20080804", 5}, { "date:20080731..20080804 s:gcc", 1}, - { "date:200808110803..now", 4}, - { "date:200808110803..today", 4}, + { "date:200808110803..now", 5}, + { "date:200808110803..today", 5}, /* { "date:now..2008-08-11-08-03", 1}, */ /* { "date:today..2008-08-11-08-03", 1}, */ - { "date:200808110801..now", 4}, + { "date:200808110801..now", 5}, }; old_tz = set_tz ("Europe/Helsinki"); @@ -427,11 +428,11 @@ test_mu_query_dates_sydney (void) /* { "date:20080804..20080731", 5}, */ { "date:20080731..20080804", 5}, { "date:20080731..20080804 s:gcc", 1}, - { "date:200808110803..now", 4}, - { "date:200808110803..today", 4}, + { "date:200808110803..now", 5}, + { "date:200808110803..today", 5}, /* { "date:now..2008-08-11-08-03", 1}, */ /* { "date:today..2008-08-11-08-03", 1}, */ - { "date:200808110801..now", 4}, + { "date:200808110801..now", 5}, }; old_tz = set_tz ("Australia/Sydney"); @@ -460,11 +461,11 @@ test_mu_query_dates_la (void) /* { "date:20080804..20080731", 5}, */ { "date:20080731..20080804", 5}, { "date:20080731..20080804 s:gcc", 1}, - { "date:200808110803..now", 3}, - { "date:200808110803..today", 3}, + { "date:200808110803..now", 4}, + { "date:200808110803..today", 4}, /* { "date:now..2008-08-11-08-03", 1}, */ /* { "date:today..2008-08-11-08-03", 1}, */ - { "date:200808110801..now", 3}, /* does not match in LA */ + { "date:200808110801..now", 4}, /* does not match in LA */ }; old_tz = set_tz ("America/Los_Angeles"); @@ -490,9 +491,9 @@ test_mu_query_sizes (void) int i; QResults queries[] = { - { "size:0b..2m", 16}, + { "size:0b..2m", 17}, { "size:2k..4k", 4}, - { "size:2m..0b", 16} + { "size:2m..0b", 17} }; xpath = fill_database (MU_TESTMAILDIR); diff --git a/src/tests/testdir/cur/multimime!2,FS b/src/tests/testdir/cur/multimime!2,FS new file mode 100644 index 00000000..84f85aae --- /dev/null +++ b/src/tests/testdir/cur/multimime!2,FS @@ -0,0 +1,27 @@ +Return-path: <> +Envelope-to: djcb@localhost +Delivery-date: Sun, 20 May 2012 09:59:51 +0300 +From: Steve Jobs +To: Bill Gates +Subject: multimime +User-agent: mu4e 0.9.8.4; emacs 23.3.1 +Date: Sat, 19 May 2012 20:57:56 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="=-=-=" + +--=-=-= +Content-Type: text/plain + +abc +--=-=-= +Content-Type: application/octet-stream +Content-Disposition: attachment; filename="test1.C" +Content-Transfer-Encoding: base64 + +aGVyZSBpcyBhIHNpbXBsZSB0ZXN0IGZpbGUuCg== +--=-=-= +Content-Type: text/plain + +def +--=-=-=--