Bug 1350080 - Prevent decoding (base64/quoted-printable) when saving or forwarding message attachments. r=jorgk a=jorgk
authorAlfred Peters <infofrommozilla@justmail.de>
Sun, 26 Mar 2017 14:15:00 +0200
changeset 27485 f69d377633cde4cfabb24aa840034fdf344dfb4d
parent 27484 52545958297b09d50b8bf1eced4e9ddc306cb25d
child 27486 15b8cc91c73ae49c7ccb2c2bdc705e9931f7c44e
push id1905
push usermozilla@jorgk.com
push dateWed, 05 Apr 2017 17:30:55 +0000
treeherdercomm-beta@b74bf497e3d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk, jorgk
bugs1350080
Bug 1350080 - Prevent decoding (base64/quoted-printable) when saving or forwarding message attachments. r=jorgk a=jorgk
mailnews/mime/src/mimeleaf.cpp
--- a/mailnews/mime/src/mimeleaf.cpp
+++ b/mailnews/mime/src/mimeleaf.cpp
@@ -86,18 +86,25 @@ MimeLeaf_finalize (MimeObject *object)
 static int
 MimeLeaf_parse_begin (MimeObject *obj)
 {
   MimeLeaf *leaf = (MimeLeaf *) obj;
   MimeDecoderData *(*fn) (MimeConverterOutputCallback, void*) = 0;
 
   /* Initialize a decoder if necessary.
    */
-  if (!obj->encoding)
-  ;
+  if (!obj->encoding ||
+      // If we need the object as "raw" for saving or forwarding,
+      // don't decode message types. Other output formats,
+      // like "display" (nsMimeMessageBodyDisplay), need decoding.
+      (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw &&
+       obj->parent &&
+       (!PL_strcasecmp(obj->parent->content_type, MESSAGE_NEWS) ||
+        !PL_strcasecmp(obj->parent->content_type, MESSAGE_RFC822))))
+    /* no-op */ ;
   else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64))
   fn = &MimeB64DecoderInit;
   else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
   leaf->decoder_data = 
           MimeQPDecoderInit(((MimeConverterOutputCallback)
                         ((MimeLeafClass *)obj->clazz)->parse_decoded_buffer),
                         obj, obj);
   else if (!PL_strcasecmp(obj->encoding, ENCODING_UUENCODE) ||