* append all inline text/plain parts for the body, add test cases
This commit is contained in:
@ -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)
|
append_text (GMimeObject *parent, GMimeObject *part, gchar **txt)
|
||||||
{
|
{
|
||||||
GMimeContentType *ct;
|
GMimeContentType *ct;
|
||||||
|
GMimeContentDisposition *disp;
|
||||||
gchar *parttxt, *tmp;
|
gchar *parttxt, *tmp;
|
||||||
gboolean err;
|
gboolean err;
|
||||||
|
|
||||||
@ -635,14 +636,15 @@ append_text (GMimeObject *parent, GMimeObject *part, gchar **txt)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ct = g_mime_object_get_content_type (part);
|
ct = g_mime_object_get_content_type (part);
|
||||||
if (!GMIME_IS_CONTENT_TYPE(ct)) {
|
if (!GMIME_IS_CONTENT_TYPE(ct) ||
|
||||||
g_warning ("%s: no content-type for part", __FUNCTION__);
|
!g_mime_content_type_is_type (ct, "text", "plain"))
|
||||||
return;
|
return; /* not a text-plain part */
|
||||||
}
|
|
||||||
|
|
||||||
/* is it right content type? */
|
disp = g_mime_object_get_content_disposition (part);
|
||||||
if (!g_mime_content_type_is_type (ct, "text", "plain"))
|
if (GMIME_IS_CONTENT_DISPOSITION(disp) &&
|
||||||
return; /* nope */
|
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);
|
parttxt = mu_msg_mime_part_to_string (GMIME_PART(part), &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -651,8 +653,7 @@ append_text (GMimeObject *parent, GMimeObject *part, gchar **txt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's a text part -- append it! note, we ignore the
|
/* it's a text part -- append it! */
|
||||||
* disposition here. */
|
|
||||||
tmp = *txt;
|
tmp = *txt;
|
||||||
if (*txt) {
|
if (*txt) {
|
||||||
*txt = g_strconcat (*txt, parttxt, NULL);
|
*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
|
/* instead of just the body, this function returns a concatenation of
|
||||||
* all text/plain parts with inline disposition
|
* all text/plain parts with inline disposition
|
||||||
*/
|
*/
|
||||||
G_GNUC_UNUSED static char*
|
static char*
|
||||||
get_concatenated_text (MuMsgFile *self)
|
get_concatenated_text (MuMsgFile *self)
|
||||||
{
|
{
|
||||||
char *txt;
|
char *txt;
|
||||||
@ -795,7 +796,7 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid,
|
|||||||
return get_recipient (self, recipient_type(mfid));
|
return get_recipient (self, recipient_type(mfid));
|
||||||
|
|
||||||
case MU_MSG_FIELD_ID_BODY_TEXT: *do_free = TRUE;
|
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;
|
case MU_MSG_FIELD_ID_BODY_HTML: *do_free = TRUE;
|
||||||
return get_body (self, TRUE);
|
return get_body (self, TRUE);
|
||||||
|
|
||||||
|
|||||||
@ -129,6 +129,7 @@ EXTRA_DIST= \
|
|||||||
testdir/cur/signed!2,S \
|
testdir/cur/signed!2,S \
|
||||||
testdir/cur/encrypted!2,S \
|
testdir/cur/encrypted!2,S \
|
||||||
testdir/cur/signed-encrypted!2,S \
|
testdir/cur/signed-encrypted!2,S \
|
||||||
|
testdir/cur/multimime!2,FS \
|
||||||
testdir2/bar/cur/mail1 \
|
testdir2/bar/cur/mail1 \
|
||||||
testdir2/bar/cur/mail2 \
|
testdir2/bar/cur/mail2 \
|
||||||
testdir2/bar/cur/mail3 \
|
testdir2/bar/cur/mail3 \
|
||||||
|
|||||||
@ -259,7 +259,7 @@ test_mu_maildir_walk_01 (void)
|
|||||||
&data);
|
&data);
|
||||||
|
|
||||||
g_assert_cmpuint (MU_OK, ==, rv);
|
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_entered,==, 5);
|
||||||
g_assert_cmpuint (data._dir_left,==, 5);
|
g_assert_cmpuint (data._dir_left,==, 5);
|
||||||
@ -297,7 +297,7 @@ test_mu_maildir_walk_02 (void)
|
|||||||
&data);
|
&data);
|
||||||
|
|
||||||
g_assert_cmpuint (MU_OK, ==, rv);
|
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_entered,==, 4);
|
||||||
g_assert_cmpuint (data._dir_left,==, 4);
|
g_assert_cmpuint (data._dir_left,==, 4);
|
||||||
|
|||||||
@ -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
|
static void
|
||||||
test_mu_msg_umlaut (void)
|
test_mu_msg_umlaut (void)
|
||||||
{
|
{
|
||||||
@ -395,6 +413,8 @@ main (int argc, char *argv[])
|
|||||||
test_mu_msg_03);
|
test_mu_msg_03);
|
||||||
g_test_add_func ("/mu-msg/mu-msg-04",
|
g_test_add_func ("/mu-msg/mu-msg-04",
|
||||||
test_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",
|
g_test_add_func ("/mu-msg/mu-msg-tags",
|
||||||
test_mu_msg_tags);
|
test_mu_msg_tags);
|
||||||
g_test_add_func ("/mu-msg/mu-msg-references",
|
g_test_add_func ("/mu-msg/mu-msg-references",
|
||||||
|
|||||||
@ -160,7 +160,7 @@ test_mu_query_01 (void)
|
|||||||
{ "foo:pepernoot", 0 },
|
{ "foo:pepernoot", 0 },
|
||||||
{ "funky", 1 },
|
{ "funky", 1 },
|
||||||
{ "fünkÿ", 1 },
|
{ "fünkÿ", 1 },
|
||||||
{ "", 16 }
|
{ "", 17 }
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -214,6 +214,7 @@ test_mu_query_03 (void)
|
|||||||
{ "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
{ "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
||||||
{ "to:help-gnu-emacs@gnu.org", 4},
|
{ "to:help-gnu-emacs@gnu.org", 4},
|
||||||
{ "t:help-gnu-emacs", 0},
|
{ "t:help-gnu-emacs", 0},
|
||||||
|
{ "flag:flagged", 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -243,9 +244,9 @@ test_mu_query_04 (void)
|
|||||||
{ "baggins", 1},
|
{ "baggins", 1},
|
||||||
{ "prio:h", 1},
|
{ "prio:h", 1},
|
||||||
{ "prio:high", 1},
|
{ "prio:high", 1},
|
||||||
{ "prio:normal", 8},
|
{ "prio:normal", 9},
|
||||||
{ "prio:l", 7},
|
{ "prio:l", 7},
|
||||||
{ "not prio:l", 9},
|
{ "not prio:l", 10},
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -394,11 +395,11 @@ test_mu_query_dates_helsinki (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 4},
|
{ "date:200808110803..now", 5},
|
||||||
{ "date:200808110803..today", 4},
|
{ "date:200808110803..today", 5},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..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");
|
old_tz = set_tz ("Europe/Helsinki");
|
||||||
@ -427,11 +428,11 @@ test_mu_query_dates_sydney (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 4},
|
{ "date:200808110803..now", 5},
|
||||||
{ "date:200808110803..today", 4},
|
{ "date:200808110803..today", 5},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..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");
|
old_tz = set_tz ("Australia/Sydney");
|
||||||
@ -460,11 +461,11 @@ test_mu_query_dates_la (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 3},
|
{ "date:200808110803..now", 4},
|
||||||
{ "date:200808110803..today", 3},
|
{ "date:200808110803..today", 4},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..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");
|
old_tz = set_tz ("America/Los_Angeles");
|
||||||
@ -490,9 +491,9 @@ test_mu_query_sizes (void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
QResults queries[] = {
|
QResults queries[] = {
|
||||||
{ "size:0b..2m", 16},
|
{ "size:0b..2m", 17},
|
||||||
{ "size:2k..4k", 4},
|
{ "size:2k..4k", 4},
|
||||||
{ "size:2m..0b", 16}
|
{ "size:2m..0b", 17}
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
|
|||||||
27
src/tests/testdir/cur/multimime!2,FS
Normal file
27
src/tests/testdir/cur/multimime!2,FS
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Return-path: <>
|
||||||
|
Envelope-to: djcb@localhost
|
||||||
|
Delivery-date: Sun, 20 May 2012 09:59:51 +0300
|
||||||
|
From: Steve Jobs <jobs@example.com>
|
||||||
|
To: Bill Gates <bg@example.com>
|
||||||
|
Subject: multimime
|
||||||
|
User-agent: mu4e 0.9.8.4; emacs 23.3.1
|
||||||
|
Date: Sat, 19 May 2012 20:57:56 +0100
|
||||||
|
Message-ID: <m2fwaw2baz.fsf@example.com>
|
||||||
|
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
|
||||||
|
--=-=-=--
|
||||||
Reference in New Issue
Block a user