Commit a55b5030 authored by Jorg K's avatar Jorg K Committed by Frank-Rainer Grahl
Browse files

Bug 394322 - Fix various forwarding issues: <html attr>, without <html>,...

Bug 394322 - Fix various forwarding issues: <html attr>, without <html>, content before <html>. r=aceman a=jorgk
parent 63b7f3a7
......@@ -22,7 +22,8 @@ Content-Type: multipart/related;
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<html>
<html attr>
<!-- This also needs to work when the html tag has an attribute -->
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
......
From: test <test@example.com>
Subject: test multipart, alternative first
To: test2 <test2@example.com>
Date: Sat, 27 Feb 2016 17:11:45 +0100
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="------------alternative"
This is a multi-part message in MIME format.
--------------alternative
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
áóúäöüß
--------------alternative
Content-Type: multipart/related;
boundary="------------related"
--------------related
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
áóúäöüß<br>
<html>
<!-- This also needs to work when there is content before the html tag :-( -->
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<img src="cid:part1" alt=""><br>
</body>
</html>
--------------related
Content-Type: image/png
Content-Transfer-Encoding: base64
Content-ID: <part1>
iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
lCEwN+YGfiYAAAAASUVORK5CYII=
--------------related--
--------------alternative--
......@@ -18,7 +18,7 @@ Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<html>
<!-- This also needs to work when there is no html tag -->
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
......@@ -26,7 +26,6 @@ Content-Transfer-Encoding: 8bit
áóúäöüß<br>
<img src="cid:part1" alt=""><br>
</body>
</html>
--------------alternative
......
......@@ -105,9 +105,17 @@ function test_utf8_forwarding_from_opened_file() {
function test_utf8_forwarding_from_via_folder() {
forwardViaFolder("./content-utf8-rel-only.eml");
forwardViaFolder("./content-utf8-rel-alt.eml");
forwardViaFolder("./content-utf8-alt-rel.eml");
forwardViaFolder("./content-utf8-rel-alt.eml"); // Also tests HTML part without <html> tag.
forwardViaFolder("./content-utf8-alt-rel.eml"); // Also tests <html attr>.
forwardViaFolder("./content-utf8-alt-rel2.eml"); // Also tests content before <html>.
// Repeat the last three in simple HTML view.
Services.prefs.setIntPref("mailnews.display.html_as", 3);
forwardViaFolder("./content-utf8-rel-alt.eml"); // Also tests HTML part without <html> tag.
forwardViaFolder("./content-utf8-alt-rel.eml"); // Also tests <html attr>.
forwardViaFolder("./content-utf8-alt-rel2.eml"); // Also tests content before <html>.
}
function teardownModule() {
Services.prefs.clearUserPref("mailnews.display.html_as");
}
......@@ -108,6 +108,8 @@ MimeInlineTextHTMLParsed_parse_eof(MimeObject *obj, bool abort_p)
return 0;
nsString& rawHTML = *(me->complete_buffer);
if (rawHTML.IsEmpty())
return 0;
nsString parsed;
nsresult rv;
......
......@@ -665,8 +665,8 @@ mime_insert_all_headers(char **body,
bool htmlEdit = (composeFormat == nsIMsgCompFormat::HTML);
char *newBody = NULL;
char *html_tag = nullptr;
if (*body)
html_tag = PL_strcasestr(*body, "<HTML>");
if (*body && PL_strncasecmp(*body, "<HTML", 5) == 0)
html_tag = PL_strchr(*body, '>') + 1;
int i;
if (!headers->done_p)
......@@ -760,7 +760,7 @@ mime_insert_all_headers(char **body,
NS_MsgSACat(&newBody, "</TABLE>");
NS_MsgSACat(&newBody, MSG_LINEBREAK "<BR><BR>");
if (html_tag)
NS_MsgSACat(&newBody, html_tag+6);
NS_MsgSACat(&newBody, html_tag);
else if (*body)
NS_MsgSACat(&newBody, *body);
}
......@@ -801,8 +801,8 @@ mime_insert_normal_headers(char **body,
char *followup_to = MimeHeaders_get(headers, HEADER_FOLLOWUP_TO, false, true);
char *references = MimeHeaders_get(headers, HEADER_REFERENCES, false, true);
const char *html_tag = nullptr;
if (*body)
html_tag = PL_strcasestr(*body, "<HTML>");
if (*body && PL_strncasecmp(*body, "<HTML", 5) == 0)
html_tag = PL_strchr(*body, '>') + 1;
bool htmlEdit = composeFormat == nsIMsgCompFormat::HTML;
if (from.IsEmpty())
......@@ -928,7 +928,7 @@ mime_insert_normal_headers(char **body,
NS_MsgSACat(&newBody, "</TABLE>");
NS_MsgSACat(&newBody, MSG_LINEBREAK "<BR><BR>");
if (html_tag)
NS_MsgSACat(&newBody, html_tag+6);
NS_MsgSACat(&newBody, html_tag);
else if (*body)
NS_MsgSACat(&newBody, *body);
}
......@@ -969,8 +969,8 @@ mime_insert_micro_headers(char **body,
char *newsgroups = MimeHeaders_get(headers, HEADER_NEWSGROUPS, false,
true);
const char *html_tag = nullptr;
if (*body)
html_tag = PL_strcasestr(*body, "<HTML>");
if (*body && PL_strncasecmp(*body, "<HTML", 5) == 0)
html_tag = PL_strchr(*body, '>') + 1;
bool htmlEdit = composeFormat == nsIMsgCompFormat::HTML;
if (from.IsEmpty())
......@@ -1047,7 +1047,7 @@ mime_insert_micro_headers(char **body,
NS_MsgSACat(&newBody, "</TABLE>");
NS_MsgSACat(&newBody, MSG_LINEBREAK "<BR><BR>");
if (html_tag)
NS_MsgSACat(&newBody, html_tag+6);
NS_MsgSACat(&newBody, html_tag);
else if (*body)
NS_MsgSACat(&newBody, *body);
}
......
......@@ -114,6 +114,8 @@ MimeInlineTextHTMLSanitized_parse_eof(MimeObject *obj, bool abort_p)
return 0;
nsString& cb = *(me->complete_buffer);
if (cb.IsEmpty())
return 0;
nsString sanitized;
// Sanitize.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment