Bug 674473 - Make MIME parts in a multipart/related context that are not referred to or cannot be displayed inline available as attachments again; r=bienvenu,a=Standard8
authorJim Porter <squibblyflabbetydoo@gmail.com>
Wed, 08 Feb 2012 20:04:57 -0600
changeset 10194 5579d69dcd4b8976d729c2fd48ce9d6db2ef1a12
parent 10193 937dbe2157f3c1cc3d5f446da4f7c667b2669188
child 10195 3f05bb53a6816464a00e6403c32998a6b1149cf5
push idunknown
push userunknown
push dateunknown
reviewersbienvenu, Standard8
bugs674473
Bug 674473 - Make MIME parts in a multipart/related context that are not referred to or cannot be displayed inline available as attachments again; r=bienvenu,a=Standard8
mailnews/mime/src/mimeleaf.cpp
mailnews/mime/src/mimemoz2.cpp
--- a/mailnews/mime/src/mimeleaf.cpp
+++ b/mailnews/mime/src/mimeleaf.cpp
@@ -83,16 +83,21 @@ MimeLeafClassInitialize(MimeLeafClass *c
 
 
 static int
 MimeLeaf_initialize (MimeObject *obj)
 {
   /* This is an abstract class; it shouldn't be directly instantiated. */
   NS_ASSERTION(obj->clazz != (MimeObjectClass *) &mimeLeafClass, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
 
+  // Initial size is -1 (meaning "unknown size") - we'll correct it in
+  // parse_buffer.
+  MimeLeaf *leaf = (MimeLeaf *) obj;
+  leaf->sizeSoFar = -1;
+
   return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(obj);
 }
 
 
 static void
 MimeLeaf_finalize (MimeObject *object)
 {
   MimeLeaf *leaf = (MimeLeaf *)object;
@@ -111,19 +116,16 @@ MimeLeaf_finalize (MimeObject *object)
 
 
 static int
 MimeLeaf_parse_begin (MimeObject *obj)
 {
   MimeLeaf *leaf = (MimeLeaf *) obj;
   MimeDecoderData *(*fn) (nsresult (*) (const char*, PRInt32, void*), void*) = 0;
 
-  // Initial size is zero
-  leaf->sizeSoFar = 0;
-
   /* Initialize a decoder if necessary.
    */
   if (!obj->encoding)
   ;
   else if (!PL_strcasecmp(obj->encoding, ENCODING_BASE64))
   fn = &MimeB64DecoderInit;
   else if (!PL_strcasecmp(obj->encoding, ENCODING_QUOTED_PRINTABLE))
   leaf->decoder_data = 
@@ -166,16 +168,19 @@ MimeLeaf_parse_buffer (const char *buffe
   /* If we're not supposed to write this object, bug out now.
    */
   if (!obj->output_p ||
     !obj->options ||
     !obj->options->output_fn)
   return 0;
 
   int rv;
+  if (leaf->sizeSoFar == -1)
+    leaf->sizeSoFar = 0;
+
   if (leaf->decoder_data &&
       obj->options && 
       obj->options->format_out != nsMimeOutput::nsMimeMessageDecrypt
       && obj->options->format_out != nsMimeOutput::nsMimeMessageAttach) {
     int outSize = 0;
     rv = MimeDecoderWrite (leaf->decoder_data, buffer, size, &outSize);
     leaf->sizeSoFar += outSize;
   }
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -521,20 +521,19 @@ BuildAttachmentList(MimeObject *anObject
        (mime_typep(anObject, (MimeObjectClass *)&mimeExternalBodyClass)))
     return NS_OK;
 
   for (i = 0; i < cobj->nchildren ; i++)
   {
     MimeObject    *child = cobj->children[i];
     char          *ct = child->content_type;
 
-    // Skip attachments that are not being output
-    if (! child->output_p)
-      continue;
-    
+    // We're going to ignore the output_p attribute because we want to output
+    // any part with a name to work around bug 674473
+
     // Skip the first child that's being output if it's in fact a message body.
     // Start by assuming that it is, until proven otherwise in the code below.
     bool skip = true;
     if (found_output)
       // not first child being output
       skip = PR_FALSE;
     else if (! ct)
       // no content type so can't be message body