Bug 580017 - Base64 encoded EML files in attachments can't be opened ("Empty attachments" by open, "Save As" does do nothing). r=bienvenu
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Tue, 21 Feb 2012 13:27:42 +0000
changeset 10884 5d709315385852799b18874c552a7c117b2d8c7a
parent 10883 81005ca684556e2fb45601c11f7eb4afad2f89a7
child 10885 61302b6893270b2bbfb7bf15865a10e8416331d1
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs580017
Bug 580017 - Base64 encoded EML files in attachments can't be opened ("Empty attachments" by open, "Save As" does do nothing). r=bienvenu
mailnews/mime/src/mimei.cpp
--- a/mailnews/mime/src/mimei.cpp
+++ b/mailnews/mime/src/mimei.cpp
@@ -890,16 +890,29 @@ mime_create (const char *content_type, M
     {
       override_content_type = opts->file_type_fn (name, opts->stream_closure);
       // appledouble isn't a valid override content type, and makes
       // attachments invisible.
       if (!PL_strcasecmp(override_content_type, MULTIPART_APPLEDOUBLE))
         override_content_type = nsnull;
       PR_FREEIF(name);
 
+      // Workaroung for saving '.eml" file encoded with base64.
+      // Do not override with message/rfc822 whenever Transfer-Encoding is
+      // base64 since base64 encoding of message/rfc822 is invalid.
+      // Our MimeMessageClass has no capability to decode it.
+      if (!PL_strcasecmp(override_content_type, MESSAGE_RFC822)) {
+        nsCString encoding;
+        encoding.Adopt(MimeHeaders_get(hdrs,
+                                       HEADER_CONTENT_TRANSFER_ENCODING,
+                                       true, false));
+        if (encoding.EqualsLiteral(ENCODING_BASE64))
+          override_content_type = nsnull;
+      }
+
       // If we get here and it is not the unknown content type from the
       // file name, let's do some better checking not to inline something bad
       if (override_content_type &&
           *override_content_type &&
           (PL_strcasecmp(override_content_type, UNKNOWN_CONTENT_TYPE)))
         content_type = override_content_type;
     }
   }