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 24437 8fef874d911a6b6919731c3234674c978c07493b
parent 24436 d5b331fe189834e81be139d2babeb509e02d2681
child 24438 2294382e95803d5dcbe9b66933c6295eb3bcab12
push id2042
push usermozilla@jorgk.com
push dateSat, 01 Apr 2017 06:10:39 +0000
treeherdercomm-aurora@d37f0a1d5fbb [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) ||