Arlolra has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350005 )

Change subject: Fix crasher from a9cfa9c9
......................................................................

Fix crasher from a9cfa9c9

 * On /hi.wikipedia.org/v3/page/html/फर्डिनैंड_कोह्न/2674115

 * Ignoring subst came from aaca5eac but doesn't seem right.  We should
   only be ignoring safesubt.

Change-Id: Ia15c4e1aa36d13ea0d25870e47f6248ca297066d
---
M lib/wt2html/tt/TemplateHandler.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/05/350005/1

diff --git a/lib/wt2html/tt/TemplateHandler.js 
b/lib/wt2html/tt/TemplateHandler.js
index 436ca09..b5d753e 100644
--- a/lib/wt2html/tt/TemplateHandler.js
+++ b/lib/wt2html/tt/TemplateHandler.js
@@ -443,7 +443,7 @@
 
        // Without a trim(), we get bug T147742 because
        // the prefix === target check further below fails!
-       target = target.trim().replace(/^(safe)?subst:/, '');
+       target = target.trim().replace(/^safesubst:/, '');
        var pieces = target.split(':');
        var prefix = pieces[0].trim();
        // The check for pieces.length > 1 is require to distinguish between
@@ -471,7 +471,7 @@
                if (typeof firstTok === 'string') {
                        targetToks = targetToks.slice(1);
                        // Strip parser-func / magic-word prefix
-                       firstTok = firstTok.replace(new RegExp("^" + prefix, 
'i'), '');
+                       firstTok = firstTok.trim().replace(new 
RegExp("^(safesubst:)?" + prefix, 'i'), '');
 
                        // Strip ":" after skipping empty tokens, if any
                        if (isPF) {
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 52941b5..883dcab 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -128,7 +128,7 @@
 add("wt2html", "Templates: Ugly nesting: 1. Quotes opened/closed across 
templates (echo)", "<p data-parsoid='{\"dsr\":[0,40,0,0]}'><i about=\"#mwt1\" 
typeof=\"mw:Transclusion\" 
data-parsoid='{\"dsr\":[0,40,null,null],\"pi\":[[{\"k\":\"1\"}],[{\"k\":\"1\"}],[{\"k\":\"1\"}]]}'
 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&#39;&#39;a\"}},\"i\":0}},{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"b&#39;&#39;c&#39;&#39;d\"}},\"i\":1}},{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&#39;&#39;e\"}},\"i\":2}}]}'>ab</i><span
 about=\"#mwt1\">c</span><i about=\"#mwt1\">d</i><span 
about=\"#mwt1\">e</span></p>");
 add("wt2html", "Templates: Ugly templates: 1. Navbox template parses badly 
leading to table misnesting\n(Parsoid-centric)", "<table about=\"#mwt1\" 
typeof=\"mw:Transclusion\" 
data-parsoid='{\"stx\":\"html\",\"dsr\":[0,32,2,null],\"firstWikitextNode\":\"TABLE_html\",\"pi\":[[{\"k\":\"1\"}]]}'
 
data-mw='{\"parts\":[\"{|\\n|\",{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo&lt;/table>\"}},\"i\":0}},\"\\n|bar\\n|}\"]}'>\n<tbody><tr><td>foo</td></tr></tbody></table><span
 about=\"#mwt1\">\n|bar\n</span>");
 add("wt2html", "Templates: Ugly templates: 4. newline-only template parameter 
inconsistency", "<span about=\"#mwt1\" typeof=\"mw:Transclusion\" 
data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[0,10,null,null]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"\\n\"}},\"i\":0}}]}'>\n</span>");
-add("wt2html", "subst: does not work during normal parse", "<p about=\"#mwt1\" 
typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[0,13,0,0],\"pi\":[[]]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"SubstTest\",\"href\":\"./Template:SubstTest\"},\"params\":{},\"i\":0}}]}'>Foobar</p>");
+add("wt2html", "subst: does not work during normal parse", "<p about=\"#mwt1\" 
typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[0,13,0,0],\"pi\":[[]]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"SubstTest\",\"href\":\"./Template:SubstTest\"},\"params\":{},\"i\":0}}]}'>{{&lt;includeonly>subst:&lt;/includeonly>Includes}}</p>");
 add("wt2html", "message transform: magic variables", "<p about=\"#mwt1\" 
typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[0,12,0,0],\"pi\":[[]]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"SITENAME\",\"function\":\"sitename\"},\"params\":{},\"i\":0}}]}'>MediaWiki</p>");
 add("wt2html", "message transform: should not transform wiki markup", "<p 
data-parsoid='{\"dsr\":[0,8,0,0]}'><i 
data-parsoid='{\"dsr\":[0,8,2,2]}'>test</i></p>");
 add("wt2html", "message transform: <noinclude> in transcluded template 
(T6926)", "<p about=\"#mwt1\" typeof=\"mw:Transclusion\" 
data-parsoid='{\"dsr\":[0,12,0,0],\"pi\":[[]]}' 
data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"Includes\",\"href\":\"./Template:Includes\"},\"params\":{},\"i\":0}}]}'>Foobar</p>");

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia15c4e1aa36d13ea0d25870e47f6248ca297066d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

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

Reply via email to