Bug 407401 - Remove namespaced ARIA support in feed parser, r=mak

--HG--
extra : rebase_source : 34b1bbb4b5144e25b7b49194bff74022a527b507
This commit is contained in:
Mark Capella 2012-03-19 21:15:26 +01:00
parent 2d7e554c3d
commit 0e109de66f
3 changed files with 2 additions and 143 deletions

View File

@ -82,7 +82,6 @@ var gIoService = null;
const XMLNS = "http://www.w3.org/XML/1998/namespace";
const RSS090NS = "http://my.netscape.com/rdf/simple/0.9/";
const WAIROLE_NS = "http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#";
/***** Some general utils *****/
function strToURI(link, base) {
@ -224,8 +223,6 @@ var gNamespaces = {
// for attributes only
var gAllowedXHTMLNamespaces = {
"http://www.w3.org/XML/1998/namespace":"xml",
"http://www.w3.org/TR/xhtml2":"xhtml2",
"http://www.w3.org/2005/07/aaa":"aaa",
// if someone ns qualifies XHTML, we have to prefix it to avoid an
// attribute collision.
"http://www.w3.org/1999/xhtml":"xhtml"
@ -886,14 +883,13 @@ function dateParse(aDateString) {
const XHTML_NS = "http://www.w3.org/1999/xhtml";
// The XHTMLHandler handles inline XHTML found in things like atom:summary
function XHTMLHandler(processor, isAtom, waiPrefixes) {
function XHTMLHandler(processor, isAtom) {
this._buf = "";
this._processor = processor;
this._depth = 0;
this._isAtom = isAtom;
// a stack of lists tracking in-scope namespaces
this._inScopeNS = [];
this._waiPrefixes = waiPrefixes;
}
// The fidelity can be improved here, to allow handling of stuff like
@ -943,39 +939,6 @@ XHTMLHandler.prototype = {
// The attribute value we'll attempt to write
var attributeValue = xmlEscape(attributes.getValue(i));
// More QName abuse from W3C
var rolePrefix = "";
if (attributes.getLocalName(i) == "role") {
for (var aPrefix in this._waiPrefixes) {
if (attributeValue.indexOf(aPrefix + ":") == 0) {
// Now, due to the terrible layer mismatch
// that is QNames in content, we have to see
// if the attribute value clashes with our
// namespace declarations.
var isCollision = false;
for (var uriKey in gAllowedXHTMLNamespaces) {
if (gAllowedXHTMLNamespaces[uriKey] == aPrefix)
isCollision = true;
}
if (isCollision) {
rolePrefix = aPrefix + i;
attributeValue =
rolePrefix + ":" +
attributeValue.substring(aPrefix.length + 1);
} else {
rolePrefix = aPrefix;
}
break;
}
}
if (rolePrefix)
this._buf += (" xmlns:" + rolePrefix +
"='" + WAIROLE_NS + "'");
}
// it's an allowed attribute NS.
// write the attribute
this._buf += (" " + prefix + ":" +
@ -1016,12 +979,8 @@ XHTMLHandler.prototype = {
this._buf += xmlEscape(data);
},
startPrefixMapping: function XH_startPrefixMapping(prefix, uri) {
if (prefix && uri == WAIROLE_NS)
this._waiPrefixes[prefix] = WAIROLE_NS;
},
endPrefixMapping: function FP_endPrefixMapping(prefix) {
if (prefix)
delete this._waiPrefixes[prefix];
},
processingInstruction: function XH_processingInstruction() {
},
@ -1135,9 +1094,6 @@ function FeedProcessor() {
this._xhtmlHandler = null;
this._haveSentResult = false;
// http://www.w3.org/WAI/PF/GUI/ uses QNames in content :(
this._waiPrefixes = {};
// The nsIFeedResultListener waiting for the parse results
this.listener = null;
@ -1487,8 +1443,7 @@ FeedProcessor.prototype = {
var type = attributes.getValueFromName("","type");
if (type != null && type.indexOf("xhtml") >= 0) {
this._xhtmlHandler =
new XHTMLHandler(this, (this._result.version == "atom"),
this._waiPrefixes);
new XHTMLHandler(this, (this._result.version == "atom"));
this._reader.contentHandler = this._xhtmlHandler;
return;
}
@ -1564,16 +1519,9 @@ FeedProcessor.prototype = {
// don't conflict with the ones we've defined, throw them in a
// dictionary to check.
startPrefixMapping: function FP_startPrefixMapping(prefix, uri) {
// Thanks for QNames in content, W3C
// This will even be a perf hit for every single feed
// http://www.w3.org/WAI/PF/GUI/
if (prefix && uri == WAIROLE_NS)
this._waiPrefixes[prefix] = WAIROLE_NS;
},
endPrefixMapping: function FP_endPrefixMapping(prefix) {
if (prefix)
delete this._waiPrefixes[prefix];
},
processingInstruction: function FP_processingInstruction(target, data) {

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Description: atom entry with many funky namespaces
Expect: var content = feed.items.queryElementAt(0, Components.interfaces.nsIFeedEntry).content;((content.text.indexOf("h2 aaa:checked") > -1) && (content.text.indexOf("h4 aaa:checked") > -1) && (content.text.indexOf("h6 xml:base") > -1));
-->
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:p="http://www.w3.org/2005/07/aaa"
xmlns:r="http://www.w3.org/TR/xhtml2">
<id>tag:example.com,2006:/atom/conformance/linktest/</id>
<title>Atom Link Tests</title>
<updated>2005-06-18T6:23:00Z</updated>
<link href="http://www.example.org" />
<entry xml:base="http://www.example.org">
<id>tag:example.org,2006:/linkreltest/1</id>
<title>Does your reader support xml:base properly? </title>
<updated>2006-06-23T12:12:12Z</updated>
<link href="foo"/>
<content type="xhtml">
<div
xmlns:aaa="http://www.w3.org/2005/07/aaa"
xmlns="http://www.w3.org/1999/xhtml">
<p xmlns:foo="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"
p:checked="true"
aaa:iconed="true" p:disabled="true">
<b r:role="asdf" aaa:iconed="true" p:disabled="true">hmm</b>
<i foo:role="asdf">hmm</i>
<h4 aaa:checked="true"></h4>
</p>
<p xmlns:foo="http://www.w3.org/2005/07/aaa">
<h2 foo:checked="true">hmm</h2>
<h6 xml:base="http://www.google.com">hmm</h6>
</p>
</div>
</content>
</entry>
</feed>

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Description: atom entry with many funky namespaces
Expect: var content = feed.items.queryElementAt(0, Components.interfaces.nsIFeedEntry).content; ((content.text.indexOf("xhtml2:role='wwwwwww") > -1) && (content.text.indexOf("xmlns:wwwwwww='http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#'") > -1) && (content.text.indexOf("xmlns:xhtml20='http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#'") > -1));
-->
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:p="http://www.w3.org/2005/07/aaa"
xmlns:r="http://www.w3.org/TR/xhtml2"
xmlns:wwwwwww="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#">
<id>tag:example.com,2006:/atom/conformance/linktest/</id>
<title>Atom Link Tests</title>
<updated>2005-06-18T6:23:00Z</updated>
<link href="http://www.example.org" />
<entry xml:base="http://www.example.org">
<id>tag:example.org,2006:/linkreltest/1</id>
<title>Does your reader support xml:base properly? </title>
<updated>2006-06-23T12:12:12Z</updated>
<link href="foo"/>
<content type="xhtml">
<div
xmlns:aaa="http://www.w3.org/2005/07/aaa"
xmlns="http://www.w3.org/1999/xhtml">
<p xmlns:foo="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"
p:checked="true"
aaa:iconed="true" p:disabled="true">
<b r:role="asdf" aaa:iconed="true" p:disabled="true">hmm</b>
<i foo:role="asdf">hmm</i>
<h4 aaa:checked="true"></h4>
</p>
<p xmlns:foo="http://www.w3.org/2005/07/aaa">
<h2 foo:checked="true">hmm</h2>
<h6 xml:base="http://www.google.com">hmm</h6>
<h3 r:role="wwwwwww:checkboxtristate">hmm</h3>
<!-- Really abusive namespace clash -->
<!-- Don't mess with this test case -->
<div xmlns:xhtml2="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#">
<p r:role="xhtml2:checkboxtristate">hmm</p>
</div>
</p>
</div>
</content>
</entry>
</feed>