From 35582bf4e29cc4aadf779d76096ef6dd47a7be1a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 8 Jun 2013 11:12:46 -0400 Subject: Bug 701669 - Bad assumption in prefer-plain module For messages with a base MIME type of multipart/alternative, we were hiding text/plain subparts based on the number of alternate subparts. This assumption of course broke on a message with the following body structure and a Plain Text Mode preference of "Show HTML if present": multipart/alternative text/plain text/plain Instead, note when we've actually seen a text/html subpart and use that to decide whether to hide the text/plain parts. --- modules/prefer-plain/e-mail-parser-prefer-plain.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'modules/prefer-plain') diff --git a/modules/prefer-plain/e-mail-parser-prefer-plain.c b/modules/prefer-plain/e-mail-parser-prefer-plain.c index 09fe450b87..6e64ab6e0f 100644 --- a/modules/prefer-plain/e-mail-parser-prefer-plain.c +++ b/modules/prefer-plain/e-mail-parser-prefer-plain.c @@ -186,6 +186,7 @@ empe_prefer_plain_parse (EMailParserExtension *extension, gint i, nparts, partidlen; CamelContentType *ct; gboolean has_calendar = FALSE; + gboolean has_html = FALSE; gboolean prefer_html; GQueue plain_text_parts = G_QUEUE_INIT; GQueue work_queue = G_QUEUE_INIT; @@ -248,6 +249,8 @@ empe_prefer_plain_parse (EMailParserExtension *extension, cancellable, &work_queue); } + has_html = TRUE; + } else if (camel_content_type_is (ct, "text", "plain")) { e_mail_parser_parse_part ( parser, sp, part_id, @@ -300,6 +303,8 @@ empe_prefer_plain_parse (EMailParserExtension *extension, e_queue_transfer (&inner_queue, &work_queue); + has_html |= multipart_has_html; + /* Parse everything else as an attachment */ } else { GQueue inner_queue = G_QUEUE_INIT; @@ -315,10 +320,10 @@ empe_prefer_plain_parse (EMailParserExtension *extension, } /* Don't hide the plain text if there's nothing else to display */ - if (has_calendar || (nparts > 1 && emp_pp->mode == PREFER_HTML)) + if (has_calendar || (has_html && prefer_html)) hide_parts (&plain_text_parts); - if (!g_queue_is_empty (&plain_text_parts) && !g_queue_is_empty (&work_queue) && nparts > 1) { + if (!g_queue_is_empty (&plain_text_parts) && !g_queue_is_empty (&work_queue) && has_html) { /* a text/html part is hidden, but not marked as attachment, * thus do that now, when there exists a text/plain part */ GList *qiter; -- cgit v1.2.3