From cfc5212d03feb3e2a9c427a89b3662d29e0c93e1 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 20 Feb 2017 18:26:27 +1100 Subject: [PATCH] Bug 1313278 - Remove code of adding xml:base attribute in nsParserUtils::ParseFragment. r=hsivonen MozReview-Commit-ID: Dyv9OlbVsaQ --HG-- extra : rebase_source : 753104a3ac84dd79f568a46cbb954a0c8a07b142 --- .../components/feeds/test/test_bug436801.html | 8 ++-- parser/html/nsParserUtils.cpp | 41 +------------------ 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/browser/components/feeds/test/test_bug436801.html b/browser/components/feeds/test/test_bug436801.html index a3661759d150..510f13033954 100644 --- a/browser/components/feeds/test/test_bug436801.html +++ b/browser/components/feeds/test/test_bug436801.html @@ -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"], diff --git a/parser/html/nsParserUtils.cpp b/parser/html/nsParserUtils.cpp index 9e0bb8c9e219..6e9b9c296fb0 100644 --- a/parser/html/nsParserUtils.cpp +++ b/parser/html/nsParserUtils.cpp @@ -162,29 +162,10 @@ nsParserUtils::ParseFragment(const nsAString& aFragment, // the fragment. nsresult rv = NS_OK; AutoTArray 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 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);