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 27852 10a70478cc88e31fec40585d41112cc6eaee04b0
parent 27851 6f372c54bde8c4b0d69e9d038a712c0f1eaece08
child 27853 31c45068f1556c74c1ccca567e213447689bbbaf
push id1880
push usermozilla@jorgk.com
push dateThu, 20 Apr 2017 13:15:21 +0000
treeherdercomm-esr52@ce2a38b113a1 [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) ||