diff --git a/mailnews/mime/src/mimethpl.cpp b/mailnews/mime/src/mimethpl.cpp index 59764a6a4835..8fdd386cc4d5 100644 --- a/mailnews/mime/src/mimethpl.cpp +++ b/mailnews/mime/src/mimethpl.cpp @@ -94,9 +94,14 @@ MimeInlineTextHTMLAsPlaintext_parse_eof (MimeObject *obj, PRBool abort_p) { if (obj->closed_p) return 0; - int status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); + + // This is a hack. We need to call parse_eof() of the super class to flush out any buffered data. + // We can't call it yet for our direct super class, because it would "close" the output + // (write tags such as and ). We'll do that after parsing the buffer. + int status = ((MimeObjectClass*)&MIME_SUPERCLASS)->superclass->parse_eof(obj, abort_p); if (status < 0) return status; + MimeInlineTextHTMLAsPlaintext *textHTMLPlain = (MimeInlineTextHTMLAsPlaintext *) obj; @@ -124,6 +129,16 @@ MimeInlineTextHTMLAsPlaintext_parse_eof (MimeObject *obj, PRBool abort_p) cb.Truncate(); + if (status < 0) + return status; + + // Second part of the flush hack. Pretend obj wasn't closed yet, so that our super class + // gets a chance to write the closing. + PRBool save_closed_p = obj->closed_p; + obj->closed_p = PR_FALSE; + status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p); + // Restore closed_p. + obj->closed_p = save_closed_p; return status; }