jenkins-bot has submitted this change and it was merged.

Change subject: Bug 70867: Set xmlns namespace URI on elements that reference it
......................................................................


Bug 70867: Set xmlns namespace URI on elements that reference it

* Creative commons snippets from the xhtml days have a bunch of xmlns
  attributes which are refused when building the dom without a namespace
  uri for the namespace reference.

* Many examples in the bug report. Here's one:
    enwiki/Talk:Marzio_Conti?oldid=561831755

* Added new parser test that crashes without this patch.

Change-Id: I864724e0c48d9d70339d7f723280f4593f67adb0
---
M lib/ext.core.Sanitizer.js
M lib/mediawiki.HTML5TreeBuilder.node.js
M tests/parserTests.txt
3 files changed, 23 insertions(+), 5 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/ext.core.Sanitizer.js b/lib/ext.core.Sanitizer.js
index 437288f..6ceda60 100644
--- a/lib/ext.core.Sanitizer.js
+++ b/lib/ext.core.Sanitizer.js
@@ -977,10 +977,9 @@
 
                // Bypass RDFa/whitelisting checks for Parsoid-inserted attrs
                // Safe to do since the tokenizer renames about/typeof attrs.
-               // unconditionally. FIXME: The escaping solution in tokenizer
-               // maybe aggressive. There is no need to escape typeof strings
+               // unconditionally. FIXME: The escaping solution in the 
tokenizer
+               // may be aggressive. There is no need to escape typeof strings
                // that or about ids that don't resemble Parsoid types/about 
ids.
-               // To be done.
                if (!psdAttr) {
                        // If RDFa is enabled, don't block XML namespace 
declaration
                        if (allowRdfa && k.match(xmlnsRE)) {
diff --git a/lib/mediawiki.HTML5TreeBuilder.node.js 
b/lib/mediawiki.HTML5TreeBuilder.node.js
index 88794b6..ee0b4ac 100644
--- a/lib/mediawiki.HTML5TreeBuilder.node.js
+++ b/lib/mediawiki.HTML5TreeBuilder.node.js
@@ -10,7 +10,8 @@
        HTML5 = require('html5'),
        domino = require('domino'),
        defines = require('./mediawiki.parser.defines.js'),
-       Util = require('./mediawiki.Util.js').Util;
+       Util = require('./mediawiki.Util.js').Util,
+       SanitizerConstants = 
require('./ext.core.Sanitizer.js').SanitizerConstants;
 
 // define some constructor shortcuts
 var CommentTk = defines.CommentTk,
@@ -95,7 +96,14 @@
 
 TreeBuilder.prototype._att = function (maybeAttribs) {
        return maybeAttribs.map(function ( attr ) {
-               return { nodeName: attr.k, nodeValue: attr.v };
+               var a = { nodeName: attr.k, nodeValue: attr.v };
+               // In the sanitizer, we've permitted the XML namespace 
declaration.
+               // Pass the appropriate URI so that domino doesn't (rightfully) 
throw
+               // a NAMESPACE_ERR.
+               if ( SanitizerConstants.XMLNS_ATTRIBUTE_RE.test(attr.k) ) {
+                       a.namespaceURI = "http://www.w3.org/2000/xmlns/";;
+               }
+               return a;
        });
 };
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 628d3cb..3120869 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -21599,6 +21599,17 @@
 <object data="test.swf"></object>
 !!end
 
+!! test
+Don't block XML namespace declaration
+!! wikitext
+<span xmlns:dct="http://purl.org/dc/terms/"; 
property="dct:title">MediaWiki</span>
+!! html/php
+<p><span>MediaWiki</span>
+</p>
+!! html/parsoid
+<p><span xmlns:dct="http://purl.org/dc/terms/"; data-x-property="dct:title" 
data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
+!! end
+
 # -----------------------------------------------------------------
 # The following section of tests are primarily to spec requirements
 # around serialization of new/edited content.

-- 
To view, visit https://gerrit.wikimedia.org/r/161129
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I864724e0c48d9d70339d7f723280f4593f67adb0
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to