Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/216126
Change subject: Don't stop on "!!" in templates
......................................................................
Don't stop on "!!" in templates
* Similar to 0d31a424b6c378adad4c21d887ae85f6607699e8
* The template depth protection is moved the tplarg_or_template rule
which seems more appropriate (and is necessary for how this fix is
constructed).
Change-Id: I82354c39d8d893817a88fbf528a4113e8f23cb08
---
M lib/mediawiki.tokenizer.utils.js
M lib/pegTokenizer.pegjs.txt
M tests/parserTests.txt
3 files changed, 40 insertions(+), 17 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/26/216126/1
diff --git a/lib/mediawiki.tokenizer.utils.js b/lib/mediawiki.tokenizer.utils.js
index ffaac1d..739f6f2 100644
--- a/lib/mediawiki.tokenizer.utils.js
+++ b/lib/mediawiki.tokenizer.utils.js
@@ -206,7 +206,9 @@
counters.tableCellArg))
) && input.substr(pos, 5) === '{{!}}';
case "!":
- return stops.onStack('th') && input[pos + 1]
=== "!";
+ return stops.onStack('th') &&
+ !stops.onCount('templatedepth') &&
+ input[pos + 1] === "!";
case "}":
return counters.template && input[pos + 1] ===
"}";
case ":":
diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index bd1f8aa..4210315 100644
--- a/lib/pegTokenizer.pegjs.txt
+++ b/lib/pegTokenizer.pegjs.txt
@@ -632,27 +632,30 @@
* 7: {{{{{{{·}}}}}}} → {·{{{·{{{·}}}·}}}·}
*/
tplarg_or_template
- = & '{{{{{{{' ob:'{' tpl:tplarg_or_template eb:'}' { return [ob, tpl, eb];
}
- / & ( '{{{' &'{{{' tplarg ) r:tplarg { return r; }
- // tplarg in template
- / & ( '{{' &'{{{' tplarg ) r:template { return r; }
- / tplarg
- / template
-
-tplarg_or_template_or_broken
- = ( & {
+ = & {
// Refuse to recurse beyond 40 levels. Default in the PHP parser
// is $wgMaxTemplateDepth = 40;
- if ( stops.onCount('templatedepth') === undefined ||
- stops.onCount('templatedepth') < 40
- ) {
- return stops.inc('templatedepth');
+ if (stops.onCount('templatedepth') === undefined ||
+ stops.onCount('templatedepth') < 40) {
+ return stops.inc('templatedepth');
} else {
- return false;
+ return false;
}
- } r:( t:tplarg_or_template { stops.dec('templatedepth'); return t; }
+ }
+ r:( & '{{{{{{{' ob:'{' tpl:tplarg_or_template eb:'}' { return [ob, tpl,
eb]; }
+ / & ( '{{{' &'{{{' tplarg ) r:tplarg { return r; }
+ // tplarg in template
+ / & ( '{{' &'{{{' tplarg ) r:template { return r; }
+ / tplarg
+ / template
+ ) {
+ stops.dec('templatedepth');
+ return r;
+ }
/ & { return stops.dec('templatedepth'); }
- ) { return r; } ) / broken_template
+
+tplarg_or_template_or_broken
+ = tplarg_or_template / broken_template
tplarg_or_template_or_bust
= (tplarg_or_template / .)+
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 1011ba8..5d6f58a 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -5681,6 +5681,24 @@
!! end
!! test
+Accept "!!" in templates
+!! wikitext
+{|
+!a {{echo|b!!c}}
+|}
+!! html/php
+<table>
+<tr>
+<th>a b</th>
+<th>c
+</th></tr></table>
+
+!! html/parsoid
+<table>
+<tbody><tr><th typeof="mw:Transclusion" about="#mwt1"
data-parsoid='{"autoInsertedEnd":true,"pi":[[{"k":"1","spc":["","","",""]}]]}'
data-mw='{"parts":["!a
",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b!!c"}},"i":0}}]}'>a
b</th><th about="#mwt1">c</th></tr>
+!! end
+
+!! test
Accept empty attributes in td/th cells (td/th cells starting with leading ||)
!! wikitext
{|
--
To view, visit https://gerrit.wikimedia.org/r/216126
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I82354c39d8d893817a88fbf528a4113e8f23cb08
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