Bug 331991 - Save as "Web Page, Complete" for HTML should include meta charset or encode all non-ASCII characters as entities
p=Ryan Jones <sciguyryan@gmail.com> r=glazou, sr=peterv git-svn-id: svn://10.0.0.236/trunk@226356 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -654,6 +654,16 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
|
||||
nsIAtom *name = content->Tag();
|
||||
|
||||
if (name == nsGkAtoms::meta) {
|
||||
// We need too skip any meta tags that set the content type
|
||||
// becase we set our own later.
|
||||
nsAutoString header;
|
||||
content->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
|
||||
if (header.LowerCaseEqualsLiteral("content-type")) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == nsGkAtoms::br && mPreLevel > 0
|
||||
&& (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) {
|
||||
AppendToString(mLineBreak, aStr);
|
||||
@@ -748,6 +758,18 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
mInCDATA = PR_TRUE;
|
||||
}
|
||||
|
||||
if (name == nsGkAtoms::head) {
|
||||
// We should also obey the line break rules set for a normal meta tag here.
|
||||
// We add a line break before and after the tag's opening.
|
||||
AppendToString(mLineBreak, aStr);
|
||||
AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""),
|
||||
aStr);
|
||||
AppendToString(NS_LITERAL_STRING(" content=\"text/html; "), aStr);
|
||||
AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr);
|
||||
AppendToString(NS_LITERAL_STRING("\">"), aStr);
|
||||
AppendToString(mLineBreak, aStr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user