[evolution] Bug 790944 - Attachment filename in multipart/mixed can be lost



commit b00d651b79493af94891a7ba23bfd4bb3ae78ee0
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 29 14:25:16 2017 +0100

    Bug 790944 - Attachment filename in multipart/mixed can be lost

 src/em-format/e-mail-parser-multipart-mixed.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/em-format/e-mail-parser-multipart-mixed.c b/src/em-format/e-mail-parser-multipart-mixed.c
index 6d3aefe..4b47d91 100644
--- a/src/em-format/e-mail-parser-multipart-mixed.c
+++ b/src/em-format/e-mail-parser-multipart-mixed.c
@@ -172,8 +172,24 @@ empe_mp_mixed_parse (EMailParserExtension *extension,
                                        dw = camel_data_wrapper_new ();
                                        camel_data_wrapper_set_mime_type (dw, snoop_type);
                                        if (camel_data_wrapper_construct_from_stream_sync (dw, mem_stream, 
cancellable, NULL)) {
+                                               const gchar *disposition;
+
                                                camel_medium_set_content (CAMEL_MEDIUM (opart), dw);
-                                               camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (opart), 
snoop_type);
+
+                                               /* Copy Content-Disposition header, if available */
+                                               disposition = camel_medium_get_header (CAMEL_MEDIUM 
(subpart), "Content-Disposition");
+                                               if (disposition)
+                                                       camel_medium_set_header (CAMEL_MEDIUM (opart), 
"Content-Disposition", disposition);
+
+                                               /* Copy also any existing parameters of the Content-Type, 
like 'name' or 'charset'. */
+                                               if (ct && ct->params) {
+                                                       CamelHeaderParam *param;
+                                                       for (param = ct->params; param; param = param->next) {
+                                                               camel_content_type_set_param (snoop_ct, 
param->name, param->value);
+                                                       }
+                                               }
+
+                                               camel_data_wrapper_set_mime_type_field (CAMEL_DATA_WRAPPER 
(opart), snoop_ct);
 
                                                handled = e_mail_parser_parse_part (parser, opart, part_id, 
cancellable, &work_queue);
                                                if (handled) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]