GWicke has uploaded a new change for review.
https://gerrit.wikimedia.org/r/70760
Change subject: Don't escape '=' in template parameter values
......................................................................
Don't escape '=' in template parameter values
{{echo|1=====}} works just fine. Only the first '=' is consumed. Positional
parameters need to be escaped as before.
Fixes a few parserTests, the blacklist is updated.
Change-Id: I8f3cf9ec2b880b567c57cbe82a35c696c085d217
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
2 files changed, 25 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/60/70760/1
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 75c55fa..e405f63 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -748,9 +748,9 @@
* General strategy:
*
* Tokenize the arg wikitext. Anything that parses as tags
- * are good and we need not bother with those. Check for harmful
- * characters "[]{}|=" in any strings and escape those fragments
- * since these characters could change semantics of the entire
+ * are good and we need not bother with those. Check for harmful
+ * characters "[]{}|" or additonally '=' in positional parameters and escape
+ * those fragments since these characters could change semantics of the entire
* template transclusion.
*
* This function makes a couple of assumptions:
@@ -760,14 +760,25 @@
* width of the opening and closing wikitext tags and not
* the entire DOM range they span in the end.
*/
-WSP.escapeTplArgWT = function(state, arg) {
+WSP.escapeTplArgWT = function(state, arg, isPositional) {
function escapeStr(str, buf) {
- if (str.match(/[\{\[\]\}\|\=]/)) {
- buf.push("<nowiki>");
- buf.push(str);
- buf.push("</nowiki>");
+ if (isPositional) {
+ // Can't allow '=' in positional parameters
+ if (str.match(/[\{\[\]\}\|\=]/)) {
+ buf.push("<nowiki>");
+ buf.push(str);
+ buf.push("</nowiki>");
+ } else {
+ buf.push(str);
+ }
} else {
- buf.push(str);
+ if (str.match(/[\{\[\]\}\|]/)) {
+ buf.push("<nowiki>");
+ buf.push(str);
+ buf.push("</nowiki>");
+ } else {
+ buf.push(str);
+ }
}
}
@@ -2647,11 +2658,15 @@
if (n > 0) {
var numericIndex = 1,
pushArg = function (k) {
- var v =
serializer.escapeTplArgWT(state, tpl.params[k].wt);
+ var v;
if (k ===
numericIndex.toString()) {
numericIndex++;
+ // Escape as positional
parameter
+ v =
serializer.escapeTplArgWT(state, tpl.params[k].wt, true);
argBuf.push(v);
} else {
+ // Escape as value only
+ v =
serializer.escapeTplArgWT(state, tpl.params[k].wt, false);
var kStr = k,
vStr = v;
diff --git a/js/tests/parserTests-blacklist.js
b/js/tests/parserTests-blacklist.js
index 0737438..00998b0 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -560,7 +560,6 @@
add("wt2wt", "Bug 2702: Mismatched <i>, <b> and <a> tags are invalid");
add("wt2wt", "External link containing double-single-quotes in text embedded
in italics (bug 4598 sanity check)");
add("wt2wt", "External link containing double-single-quotes with no space
separating the url from text in italics");
-add("wt2wt", "URL-encoding in URL functions (multiple parameters)");
add("wt2wt", "Unclosed and unmatched quotes (parsoid)");
add("wt2wt", "A table with captions with non-default spaced attributes and a
table row");
add("wt2wt", "Table td-cell syntax variations");
@@ -2665,9 +2664,6 @@
add("selser", "External link containing double-single-quotes with no space
separating the url from text in italics [[[0,4],4,3]]");
add("selser", "External link containing double-single-quotes with no space
separating the url from text in italics [[4,0,3]]");
add("selser", "External link containing double-single-quotes with no space
separating the url from text in italics [[[1,2],2,4]]");
-add("selser", "URL-encoding in URL functions (multiple parameters) 0");
-add("selser", "URL-encoding in URL functions (multiple parameters) [2]");
-add("selser", "URL-encoding in URL functions (multiple parameters) [1]");
add("selser", "Quotes [1,0,[4,2,4,4]]");
add("selser", "Quotes [2,0,1]");
add("selser", "Quotes [[4,0,2,0],0,1]");
--
To view, visit https://gerrit.wikimedia.org/r/70760
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f3cf9ec2b880b567c57cbe82a35c696c085d217
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits