[MediaWiki-commits] [Gerrit] Token constructor shouldn't be a Number - change (mediawiki...parsoid)

2015-11-29 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Token constructor shouldn't be a Number
..


Token constructor shouldn't be a Number

 * The blacklist change is because of the String() wrap of the namespace
   number. In the Sanitizer, there is a test for the method
   token.isHTMLTag, which is a little smelly considering we're
   adding to a native object's prototype. Turns out, for the that
   NAMESPACENUMBER magic word, the token was being emitted as Number,
   and thus taking a different path than expected.

Change-Id: I57211d9e75b4c0448bd2a86a3d5f86ea5a714a27
---
M lib/wt2html/tt/ParserFunctions.js
M tests/parserTests-blacklist.js
2 files changed, 3 insertions(+), 3 deletions(-)

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



diff --git a/lib/wt2html/tt/ParserFunctions.js 
b/lib/wt2html/tt/ParserFunctions.js
index 5e7519b..ab34f35 100644
--- a/lib/wt2html/tt/ParserFunctions.js
+++ b/lib/wt2html/tt/ParserFunctions.js
@@ -829,7 +829,7 @@
 };
 ParserFunctions.prototype.pf_namespacenumber = function(token, frame, cb, 
args) {
var target = args[0].k.split(':').pop();
-   cb({ tokens: [this.env.conf.wiki.namespaceIds[target]] });
+   cb({ tokens: [String(this.env.conf.wiki.namespaceIds[target])] });
 };
 ParserFunctions.prototype.pf_pagename = function(token, frame, cb, args) {
cb({ tokens: [this.env.page.name || ''] });
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index afe39e9..6c7e6a2 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -76,7 +76,7 @@
 add("wt2html", "Magic Word: {{SUBJECTSPACEE}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTSPACEE");
 add("wt2html", "Magic Word: {{NAMESPACE}}", "Main");
 add("wt2html", "Magic Word: {{NAMESPACEE}}", "Main");
-add("wt2html", "Magic Word: {{NAMESPACENUMBER}}", "");
+add("wt2html", "Magic Word: {{NAMESPACENUMBER}}", "0");
 add("wt2html", "Magic Word: {{SUBPAGENAME}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME");
 add("wt2html", "Magic Word: {{SUBPAGENAMEE}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE");
 add("wt2html", "Magic Word: {{ROOTPAGENAME}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME");
@@ -189,7 +189,7 @@
 add("wt2html", "Transclusion of MediaWiki message with underscore", "Warning:
 Page/template fetching disabled, and no cache for 
MediaWiki:History_short");
 add("wt2html", "Transclusion of MediaWiki message with space", "Warning:
 Page/template fetching disabled, and no cache for 
MediaWiki:History_short");
 add("wt2html", "Special:Search page linking.", "Parser
 function implementation for pf_special missing in Parsoid.");
-add("wt2html", "Say the magic word", " 
Parser
 test\n \n Parser
 test\n Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAMEE\n 
Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAME\n Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAMEE\n Main\n Main\n \n Talk\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKSPACEE\n 
Main\n Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTSPACEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:Dynamic");
+add("wt2html", "Say the magic word", " 
Parser
 test\n \n Parser
 test\n Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAMEE\n 
Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAME\n Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAMEE\n Main\n Main\n 0\n Talk\n Warning:
 

[MediaWiki-commits] [Gerrit] Token constructor shouldn't be a Number - change (mediawiki...parsoid)

2015-11-25 Thread Arlolra (Code Review)
Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/255409

Change subject: Token constructor shouldn't be a Number
..

Token constructor shouldn't be a Number

 * The blacklist change is because of the String() wrap of the namespace
   number. In the Sanitizer, there is a test for the method
   token.isHTMLTag, which is a little smelly considering we're
   adding to a native object's prototype. Turns out, for the that
   NAMESPACENUMBER magic word, the token was being emitted as Number,
   and thus taking a different path than expected.

Change-Id: I57211d9e75b4c0448bd2a86a3d5f86ea5a714a27
---
M lib/wt2html/tt/ParserFunctions.js
M tests/parserTests-blacklist.js
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/09/255409/1

diff --git a/lib/wt2html/tt/ParserFunctions.js 
b/lib/wt2html/tt/ParserFunctions.js
index 5e7519b..ab34f35 100644
--- a/lib/wt2html/tt/ParserFunctions.js
+++ b/lib/wt2html/tt/ParserFunctions.js
@@ -829,7 +829,7 @@
 };
 ParserFunctions.prototype.pf_namespacenumber = function(token, frame, cb, 
args) {
var target = args[0].k.split(':').pop();
-   cb({ tokens: [this.env.conf.wiki.namespaceIds[target]] });
+   cb({ tokens: [String(this.env.conf.wiki.namespaceIds[target])] });
 };
 ParserFunctions.prototype.pf_pagename = function(token, frame, cb, args) {
cb({ tokens: [this.env.page.name || ''] });
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index afe39e9..6c7e6a2 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -76,7 +76,7 @@
 add("wt2html", "Magic Word: {{SUBJECTSPACEE}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTSPACEE");
 add("wt2html", "Magic Word: {{NAMESPACE}}", "Main");
 add("wt2html", "Magic Word: {{NAMESPACEE}}", "Main");
-add("wt2html", "Magic Word: {{NAMESPACENUMBER}}", "");
+add("wt2html", "Magic Word: {{NAMESPACENUMBER}}", "0");
 add("wt2html", "Magic Word: {{SUBPAGENAME}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME");
 add("wt2html", "Magic Word: {{SUBPAGENAMEE}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE");
 add("wt2html", "Magic Word: {{ROOTPAGENAME}}", "Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME");
@@ -189,7 +189,7 @@
 add("wt2html", "Transclusion of MediaWiki message with underscore", "Warning:
 Page/template fetching disabled, and no cache for 
MediaWiki:History_short");
 add("wt2html", "Transclusion of MediaWiki message with space", "Warning:
 Page/template fetching disabled, and no cache for 
MediaWiki:History_short");
 add("wt2html", "Special:Search page linking.", "Parser
 function implementation for pf_special missing in Parsoid.");
-add("wt2html", "Say the magic word", " 
Parser
 test\n \n Parser
 test\n Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAMEE\n 
Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAME\n Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAMEE\n Main\n Main\n \n Talk\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKSPACEE\n 
Main\n Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTSPACEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:Dynamic");
+add("wt2html", "Say the magic word", " 
Parser
 test\n \n Parser
 test\n Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:BASEPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAME\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:ROOTPAGENAMEE\n 
Parser
 test\n Warning:
 Page/template fetching disabled, and no cache for 
Template:TALKPAGENAMEE\n 
Warning:
 Page/template fetching disabled, and no cache for 
Template:SUBJECTPAGENAME\n Warning:
 Page/template fetching disabled, and no cache for