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.
This commit is contained in:
Matthew Barnes
2013-06-08 11:12:46 -04:00
parent 5cf06f855f
commit 35582bf4e2

View File

@ -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;