jenkins-bot has submitted this change and it was merged.
Change subject: T147742: Trim template target after stripping comments
..
T147742: Trim template target after stripping comments
* Updated an existing test + fixed up blacklist.
Change-Id: If69246776b165f833ae58fdaf72eaced0fd2f255
---
M lib/wt2html/tt/TemplateHandler.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 33 insertions(+), 24 deletions(-)
Approvals:
Arlolra: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/wt2html/tt/TemplateHandler.js
b/lib/wt2html/tt/TemplateHandler.js
index b26cea1..adac655 100644
--- a/lib/wt2html/tt/TemplateHandler.js
+++ b/lib/wt2html/tt/TemplateHandler.js
@@ -421,8 +421,11 @@
if (tgtInfo.isStr && !tgtInfo.isSimpleTgt) {
// resolvabilityInfo found a new target based on the target
tokens. This
// happens when the target contains special characters,
specially quotes.
- // For an example look at T96090.
- target = tgtInfo.newTarget;
+ // For an example, look at T96090.
+
+ // Without a trim(), we get bug T147742 because
+ // the prefix === target check below fails!
+ target = tgtInfo.newTarget.trim();
pieces = target.split(':');
prefix = pieces[0].trim();
lowerPrefix = prefix.toLowerCase();
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index e283b6a..98db18c 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -283,7 +283,7 @@
add("wt2wt", " inside (bug 13238)",
"\n\n\n\n\n\nnowikiFoo");
add("wt2wt", " and preference (first one wins)",
"\n\n\n\n\n\n\n\nnowiki\n\n\n\n");
add("wt2wt", "Templates: Indent-Pre: 1f: Wrapping should be based on expanded
content", "{{echo| }}a\n\n{{echo|\n }}a\n\n{{echo|\n b}}\n\n{{echo|a\n
}}b\n\n{{echo|a\n}}\n b\n");
-add("wt2wt", "Templates: Handle comments in the target", "{{echo\n\n|foo}}\n\n{{echo\n|foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}");
+add("wt2wt", "Templates: Handle comments in the target", "{{echo\n\n|foo}}\n\n{{echo\n\n |foo}}\n\n{{echo\n|foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}");
add("wt2wt", "4. Indent-Pre and extension tags", " a ");
add("wt2wt", "Definition lists: self-closed tag", ";onetwo : two-line
fun");
add("wt2wt", "Definition Lists: colons occurring in tags",
";a:b\n;'''a:b'''\n;a:b\n;a:b\n;a:b\n;a\n:b\n;{{echo|a:b}}\n;{{echo|''a:b''}}\n;;;''a:b''\n");
@@ -397,7 +397,7 @@
add("html2html", " with forbidden attribute values (bug 3202)", "Narrow screen goodies\n");
add("html2html", " inside (bug 13238)", "nowiki>\n\n
\n\nnowiki>Foo/nowiki>\n");
add("html2html", " and preference (first one wins)", "nowiki>\n\n/nowiki>\n/pre>\n\n\npre>\nnowiki>\n/pre>\n\n/pre>\n");
-add("html2html", "Templates: Handle comments in the target", "foo\n\nfoo\n\nfoo\n\nfoo");
+add("html2html", "Templates: Handle comments in the target", "foo\n\nfoo\n\nfoo\n\nfoo\n\nfoo");
add("html2html", "Templates: Handle comments in parameter names (bug 67657)",
"foo\n\nfoo\n\nfoo\n\nfoo");
add("html2html", "Templates: Other wikitext in parameter names (bug 67657)",
"foo");
add("html2html", "2g. Indented table markup mixed with indented pre content
(proposed in bug 6200)", " \n \nText that should be rendered preformatted
\n|}\n");
@@ -673,7 +673,7 @@
add("html2wt", "Templates: Strip leading and trailing whitespace from
named-param values", "a\n\nb\n\nc\n\n* d\n");
add("html2wt", "Templates: Don't strip whitespace from positional-param
values", "a \n\nb \n\n c \n\n\n\n d\n\n\n\n e\n\n\n\n* f\n\n\n g\n");
add("html2wt", "Templates: Handle empty comment-and-ws-only lines correctly",
"foo\nbar\n");
-add("html2wt", "Templates: Handle comments in the target", "{{echo |foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}");
+add("html2wt", "Templates: Handle comments in the target", "{{echo |foo}}\n\n{{echo |foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}\n\n{{echo|foo}}");
add("html2wt", "Templates: Handle comments in parameter names (bug 67657)",
"{{echo|1 =foo}}\n\n{{echo|
1=foo}}\n\n{{echo|1=foo}}\n\n{{echo|1=foo}}");
add("html2wt", "1a. Indent-Pre and Comments", " a\n\nc\n");
add("html2wt", "1b. Indent-Pre and Comments", " a\n\nc\n");
@@ -1343,25 +1343,25 @@
add("selser", "Templates: Indent-Pre: 1f: Wrapping should be based on expanded
content [0,0,0,0,0,0,0,0,0,0,0,4,0,0,0]", "{{echo| }}a\n\n{{echo|\n
}}a\n\n{{echo|\n b}}\n\n{{echo|a\n }}b\nbt5yrxqcb1d78pvi{{echo|a\n}} b");
add("selser", "Templates: Indent-Pre: 1f: Wrapping should be based on expanded
content [0,0,0,0,4,0,0,0,0,0,0,0,0,0,[2]]", "{{echo| }}a\n\n{{echo|\n
}}a\n4kifb531krdd9529{{echo|\n b}}\n\n{{echo|a\n }}b\n\n{{echo|a\n}}
7ujkiku3nn7mn29b");
add("selser", "Templates: Indent-Pre: 1f: Wrapping should be based on expanded
content