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

MozReview-Commit-ID: Dyv9OlbVsaQ

--HG--
extra : rebase_source : 753104a3ac84dd79f568a46cbb954a0c8a07b142
This commit is contained in:
Xidorn Quan 2017-02-20 18:26:27 +11:00
Родитель 7bcb3baa94
Коммит cfc5212d03
2 изменённых файлов: 6 добавлений и 43 удалений

Просмотреть файл

@ -23,7 +23,7 @@ addLoadEvent(function() {
var doc = SpecialPowers.wrap($("testFrame")).contentDocument;
checkNode(doc.getElementById("feedTitleText"), [
"ELEMENT", "h1", { "xml:base": "http://www.example.com/foo/bar/" }, [
"ELEMENT", "h1", [
["TEXT", "Example of a "],
["ELEMENT", "em", [
["TEXT", "special"],
@ -35,7 +35,7 @@ addLoadEvent(function() {
]);
checkNode(doc.getElementById("feedSubtitleText"), [
"ELEMENT", "h2", { "xml:base": "http://www.example.com/foo/bar/" }, [
"ELEMENT", "h2", [
["TEXT", "With a "],
["ELEMENT", "em", [
["TEXT", "special"],
@ -47,7 +47,7 @@ addLoadEvent(function() {
]);
checkNode(doc.querySelector(".entry").firstChild.firstChild.firstChild, [
"ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [
"ELEMENT", "span", [
["TEXT", "Some "],
["ELEMENT", "abbr", { title: "Extensible Hyper-text Mark-up Language" }, [
["TEXT", "XHTML"],
@ -59,7 +59,7 @@ addLoadEvent(function() {
]);
checkNode(doc.querySelectorAll(".entry")[1].firstChild.firstChild.firstChild, [
"ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [
"ELEMENT", "span", [
["TEXT", "Some "],
["ELEMENT", "abbr", { title: "Hyper-text Mark-up Language" }, [
["TEXT", "HTML"],

Просмотреть файл

@ -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);