Bug 1313278 - Remove code of adding xml:base attribute in nsParserUtils::ParseFragment. r=hsivonen

MozReview-Commit-ID: Dyv9OlbVsaQ
This commit is contained in:
Xidorn Quan
2017-02-20 18:26:27 +11:00
parent 8358f212f7
commit 606bc653cf
2 changed files with 6 additions and 43 deletions

View File

@@ -162,29 +162,10 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
// the fragment.
nsresult rv = NS_OK;
AutoTArray<nsString, 2> tagStack;
nsAutoCString base, spec;
if (aIsXML) {
// XHTML
if (aBaseURI) {
base.AppendLiteral(XHTML_DIV_TAG);
base.AppendLiteral(" xml:base=\"");
rv = aBaseURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
// nsEscapeHTML is good enough, because we only need to get
// quotes, ampersands, and angle brackets
char* escapedSpec = nsEscapeHTML(spec.get());
if (escapedSpec)
base += escapedSpec;
free(escapedSpec);
base.Append('"');
tagStack.AppendElement(NS_ConvertUTF8toUTF16(base));
} else {
tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
}
}
nsCOMPtr<nsIContent> fragment;
if (aIsXML) {
// XHTML
tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
rv = nsContentUtils::ParseFragmentXML(aFragment,
document,
tagStack,
@@ -200,24 +181,6 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
kNameSpaceID_XHTML,
false,
true);
// Now, set the base URI on all subtree roots.
if (aBaseURI) {
nsresult rv2 = aBaseURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv2, rv2);
nsAutoString spec16;
CopyUTF8toUTF16(spec, spec16);
nsIContent* node = fragment->GetFirstChild();
while (node) {
if (node->IsElement()) {
node->SetAttr(kNameSpaceID_XML,
nsGkAtoms::base,
nsGkAtoms::xml,
spec16,
false);
}
node = node->GetNextSibling();
}
}
}
if (fragment) {
nsTreeSanitizer sanitizer(aFlags);