diff options
author | Milan Crha <mcrha@redhat.com> | 2013-01-18 03:07:03 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-01-18 03:07:03 +0800 |
commit | 37699de983b6085e5be6a92eafbee07bdcc70854 (patch) | |
tree | b1fe19e92719c0916176cdb9e8e44d0c8ac383d7 /em-format/e-mail-parser-multipart-related.c | |
parent | af24ac867a7a92f7c091185c8332655965fe662a (diff) | |
download | gsoc2013-evolution-37699de983b6085e5be6a92eafbee07bdcc70854.tar.gz gsoc2013-evolution-37699de983b6085e5be6a92eafbee07bdcc70854.tar.zst gsoc2013-evolution-37699de983b6085e5be6a92eafbee07bdcc70854.zip |
Bug #691732 - multipart/related hides attachments
Diffstat (limited to 'em-format/e-mail-parser-multipart-related.c')
-rw-r--r-- | em-format/e-mail-parser-multipart-related.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/em-format/e-mail-parser-multipart-related.c b/em-format/e-mail-parser-multipart-related.c index f58a5a0f97..a1cbbf7a41 100644 --- a/em-format/e-mail-parser-multipart-related.c +++ b/em-format/e-mail-parser-multipart-related.c @@ -52,6 +52,8 @@ empe_mp_related_parse (EMailParserExtension *extension, { CamelMultipart *mp; CamelMimePart *body_part, *display_part = NULL; + CamelContentType *display_content_type; + gchar *html_body = NULL; gint i, nparts, partidlen, displayid = 0; mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part); @@ -69,6 +71,27 @@ empe_mp_related_parse (EMailParserExtension *extension, parser, part, part_id, "multipart/mixed", cancellable, out_mail_parts); + display_content_type = camel_mime_part_get_content_type (display_part); + if (display_content_type && + camel_content_type_is (display_content_type, "text", "html")) { + CamelDataWrapper *dw; + + dw = camel_medium_get_content ((CamelMedium *) display_part); + if (dw) { + CamelStream *mem = camel_stream_mem_new (); + GByteArray *bytes; + + camel_data_wrapper_decode_to_stream_sync (dw, mem, cancellable, NULL); + camel_stream_close (mem, cancellable, NULL); + + bytes = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (mem)); + if (bytes && bytes->len) + html_body = g_strndup ((const gchar *) bytes->data, bytes->len); + + g_object_unref (mem); + } + } + /* The to-be-displayed part goes first */ partidlen = part_id->len; g_string_append_printf (part_id, ".related.%d", displayid); @@ -103,13 +126,15 @@ empe_mp_related_parse (EMailParserExtension *extension, EMailPart *mail_part = link->data; /* Don't render the part on it's own! */ - if (mail_part->cid != NULL) + if (e_mail_part_utils_body_refers (html_body, mail_part->cid)) mail_part->is_hidden = TRUE; } e_queue_transfer (&work_queue, out_mail_parts); } + g_free (html_body); + return TRUE; } |