jenkins-bot has submitted this change and it was merged.
Change subject: Bug 56195: Only trigger indent-pre on space
......................................................................
Bug 56195: Only trigger indent-pre on space
Change-Id: I4f8255d03dce047e96b60f0dee3909fb3c96fe37
---
M js/lib/ext.core.PreHandler.js
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
3 files changed, 13 insertions(+), 21 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/js/lib/ext.core.PreHandler.js b/js/lib/ext.core.PreHandler.js
index b13c92b..ad4ac3b 100644
--- a/js/lib/ext.core.PreHandler.js
+++ b/js/lib/ext.core.PreHandler.js
@@ -325,12 +325,12 @@
} else {
switch (this.state) {
case PreHandler.STATE_SOL:
- if ((tc === String) && token.match(/^\s/) &&
!this.inPre) {
+ if ((tc === String) && token.match(/^ /) &&
!this.inPre) {
ret = this.tokens;
this.tokens = [];
this.preWSToken = token[0];
this.state = PreHandler.STATE_PRE;
- if (!token.match(/^\s$/)) {
+ if (!token.match(/^ $/)) {
// Treat everything after the
first space
// as a new token
this.onAny(token.slice(1),
manager, cb);
@@ -379,7 +379,7 @@
break;
case PreHandler.STATE_MULTILINE_PRE:
- if ((tc === String) && token.match(/^\s/)) {
+ if ((tc === String) && token.match(/^ /)) {
this.popLastNL(this.tokens);
this.state =
PreHandler.STATE_PRE_COLLECT;
@@ -389,7 +389,7 @@
// check if token is single-space or
more
this.multiLinePreWSToken = token[0];
- if (!token.match(/^\s$/)) {
+ if (!token.match(/^ $/)) {
// Treat everything after the
first space as a new token
this.onAny(token.slice(1),
manager, cb);
}
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 4edd88f..e355af2 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -623,7 +623,7 @@
switch (t.constructor) {
case String:
if (t.length > 0) {
- if (sol && t.match(/(^|\n)[ \t]/)) {
+ if (sol && t.match(/(^|\n) /)) {
smartNowikier(true, true, t, i,
n);
} else {
buf.push(t);
@@ -780,7 +780,7 @@
// Quick check for the common case (useful to kill a majority of
requests)
//
// Pure white-space or text without wt-special chars need not be
analyzed
- if (!fullCheckNeeded && !/(^|\n)[
\t]+[^\s]+|[<>\[\]\-\+\|'!=#\*:;~{}]|__[^_]*__/.test(text)) {
+ if (!fullCheckNeeded && !/(^|\n)
+[^\s]+|[<>\[\]\-\+\|'!=#\*:;~{}]|__[^_]*__/.test(text)) {
if (this.traceWTE) {
console.warn("---No-checks needed---");
}
@@ -817,7 +817,7 @@
// Test 1: '', [], <> need escaping wherever they occur
// = needs escaping in end-of-line context
// Test 2: {|, |}, ||, |-, |+, , *#:;, ----, =*= need escaping
only in SOL context.
- if (!sol && !text.match(/''|[<>]|\[.*\]|\]|(=[ \t]*(\n|$))/)) {
+ if (!sol && !text.match(/''|[<>]|\[.*\]|\]|(=[ ]*(\n|$))/)) {
// It is not necessary to test for an unmatched opening
bracket ([)
// as long as we always escape an unmatched closing
bracket (]).
if (this.traceWTE) {
@@ -828,7 +828,7 @@
// Quick checks when on a newline
// + can only occur as "|+" and - can only occur as "|-" or ----
- if (sol && !text.match(/(^|\n)[
\t#*:;=]|[<\[\]>\|'!]|\-\-\-\-|__[^_]*__/)) {
+ if (sol && !text.match(/(^|\n)[
#*:;=]|[<\[\]>\|'!]|\-\-\-\-|__[^_]*__/)) {
if (this.traceWTE) {
console.warn("---SOL and safe---");
}
@@ -840,7 +840,7 @@
// and moved them to a stream handler. So, we always conservatively
// escape text with ' ' in sol posn with one caveat
// * indent-pres are disabled in ref-bodies (See ext.core.PreHandler.js)
- if (sol && (this.options.extName !== 'ref') && text.match(/(^|\n)[
\t]+[^\s]+/)) {
+ if (sol && (this.options.extName !== 'ref') && text.match(/(^|\n)
+[^\s]+/)) {
if (this.traceWTE) {
console.warn("---SOL and pre---");
}
diff --git a/js/tests/parserTests-blacklist.js
b/js/tests/parserTests-blacklist.js
index 413f8d2..9934eb6 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -45,7 +45,6 @@
add("wt2html", "Entities inside <nowiki>");
add("wt2html", "Comment on its own line post-expand");
add("wt2html", "Comment on its own line post-expand with non-significant
whitespace");
-add("wt2html", "Tabs don't trigger preformatted text");
add("wt2html", "Bug 52763: Preformatted in <blockquote>");
add("wt2html", "Templates: Indent-Pre: 1a. Templates that break a line should
suppress <pre>");
add("wt2html", "Templates: Indent-Pre: 1b. Templates that break a line should
suppress <pre>");
@@ -543,10 +542,8 @@
add("wt2wt", "Non-word characters don't terminate tag names (bug 17663, 40670,
52022)");
add("wt2wt", "Bare pipe character (bug 52363)");
add("wt2wt", "Comment semantics: unclosed comment at end");
-add("wt2wt", "Tabs don't trigger preformatted text");
add("wt2wt", "<nowiki> inside <pre> (bug 13238)");
add("wt2wt", "<nowiki> and <pre> preference (first one wins)");
-add("wt2wt", "4. Multiple spaces at start-of-line");
add("wt2wt", "5. White-space in indent-pre\nNOTE: the white-space char on 2nd
line is significant");
add("wt2wt", "6. Pre-blocks should extend across lines with leading WS even
when there is no wrappable content");
add("wt2wt", "HTML-pre: 1. embedded newlines");
@@ -2419,10 +2416,8 @@
add("selser", "Comment semantics: unclosed comment at end [3]", "<!--This
comment will run out to the end of the document");
add("selser", "Comment semantics: unclosed comment at end [4]", "<!--This
comment will run out to the end of the document");
add("selser", "Comment semantics: unclosed comment at end [2]", "<!--This
comment will run out to the end of the document");
-add("selser", "Tabs don't trigger preformatted text [[4]]", "\tThis is not\n\t
preformatted text.\n This is preformatted text.\n \tSo is this.");
-add("selser", "Tabs don't trigger preformatted text [2]",
"l7wt6v8iaiwzh0k9\n\tThis is not\n\t preformatted text.\n This is preformatted
text.\n \tSo is this.");
-add("selser", "Tabs don't trigger preformatted text [[3]]", "\tThis is not\n\t
preformatted text.\n This is preformatted text.\n \tSo is this.");
-add("selser", "Tabs don't trigger preformatted text [[2]]", "\tThis is not\n\t
preformatted text.\n This is preformatted text.\n \tSo is this.");
+add("selser", "Tabs don't trigger preformatted text [2,2,[2]]",
"l7wt6v8iaiwzh0k9\t\n\nThis is not\n\t preformatted text.\n This is
preformatted text.\n \tSo is this.");
+add("selser", "Tabs don't trigger preformatted text [2,0,0]",
"pgtgiah3b7f1or\t\n\nThis is not\n\t preformatted text.\n This is preformatted
text.\n \tSo is this.");
add("selser", "<nowiki> inside <pre> (bug 13238) [4,2,2,0,0]",
"ptjux9vq9zarlik9\ny7rebotz1jo1dcxr<pre>\n<nowiki></nowiki>\n</pre>\n<pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>");
add("selser", "<nowiki> inside <pre> (bug 13238) [0,0,4,0,[[4],0,2,4]]",
"<pre>\n<nowiki>\n</pre>\n4bu012lyu5l8fr\n<pre><nowiki><nowiki></nowiki>Foo3iwsls5l4dzhbyb9<nowiki></nowiki></nowiki></pre>");
add("selser", "<nowiki> inside <pre> (bug 13238) [3,0,3,3,2]",
"\np32i6amoddb9y66r<pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>");
@@ -2445,9 +2440,6 @@
add("selser", "<nowiki> and <pre> preference (first one wins)
[2,4,[2,0],4,[[3],0],0]",
"kg5ysu07a5uerk9<pre>\n<nowiki>\n</pre>\nbs9yk9e1o4r3haor</nowiki>\n</pre>\n\n<nowiki>\n<pre>\n<nowiki>\n</pre>\n</nowiki>\n</pre>\n");
add("selser", "2a. Indent-Pre and tables [4,[0,[[3,0,3,3,[4],2],0]]]", " {|\n
|-\n !h1\n |foo||bar\n |}");
add("selser", "2c. Indent-Pre and tables (bug 42252) [[0,0,3,2]]", "{|\n |+
foo\n ! | bar\n|}");
-add("selser", "4. Multiple spaces at start-of-line [2,0,0,2]", " <p> foo
</p>\njmxd0hb7sz1wnrk9\n foo\n\t{|\n|foo\n|}");
-add("selser", "4. Multiple spaces at start-of-line [2,2,0,2]", "
zob5sdimzbzqia4i<p> foo </p>\n0ngw4sd25b87iudi\n foo\n\t{|\n|foo\n|}");
-add("selser", "4. Multiple spaces at start-of-line [0,3,0,2]", "
\n8ywnhcpkr93haor\n foo\n\t{|\n|foo\n|}");
add("selser", "5. White-space in indent-pre\nNOTE: the white-space char on 2nd
line is significant [[3,0,4]]", " a<br/>\n \n b");
add("selser", "5. White-space in indent-pre\nNOTE: the white-space char on 2nd
line is significant [2]", "zj3bbk6ucui8uxr\n a<br/>\n \n b");
add("selser", "5. White-space in indent-pre\nNOTE: the white-space char on 2nd
line is significant [1]", " a<br/>\n \n b");
@@ -3305,9 +3297,9 @@
add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[0,[4],3]]", "<div itemscope>\n\t<meta itemprop=\"hello\"
content=\"world\">\n\t<meta http-equiv=\"refresh\" content=\"5\">\n\t<meta
itemprop=\"hello\" http-equiv=\"refresh\" content=\"5\">\n\t<link
itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\" itemprop=\"hello\"
href=\"{{SERVER}}\">\n</div>");
add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[0,[2],0]]", "<div itemscope>\n\t<meta itemprop=\"hello\"
content=\"world\">\n\t<meta http-equiv=\"refresh\" content=\"5\">\n\t<meta
itemprop=\"hello\" http-equiv=\"refresh\" content=\"5\">\n\t<link
itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\" itemprop=\"hello\"
href=\"{{SERVER}}\">\n</div>");
add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [1]", "<div itemscope=\"\" data-foobar=\"q8adwgvp6owjc3di\">\n\t<meta
itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\"
content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\"
content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link
rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
itemprop=\"hello\" href=\"{{SERVER}}\">\n</div>");
-add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[2,2,0]]", "<div itemscope=\"\">\ntphlnpjbn019k9\n\t<meta
itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\"
content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\"
content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link
rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
itemprop=\"hello\" href=\"{{SERVER}}\">\n</div>");
+add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[2,2,0]]", "<div itemscope=\"\">\n\ttphlnpjbn019k9\n\n<meta
itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\"
content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\"
content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link
rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
itemprop=\"hello\" href=\"{{SERVER}}\">\n</div>");
add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[3,0,4]]", "<div itemscope>\n\t<meta itemprop=\"hello\"
content=\"world\">\n\t<meta http-equiv=\"refresh\" content=\"5\">\n\t<meta
itemprop=\"hello\" http-equiv=\"refresh\" content=\"5\">\n\t<link
itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\" itemprop=\"hello\"
href=\"{{SERVER}}\">\n</div>");
-add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[0,2,0]]", "<div itemscope=\"\">\nq21hg5f5s2kxzuxr\n\t<meta
itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\"
content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\"
content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link
rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
itemprop=\"hello\" href=\"{{SERVER}}\">\n</div>");
+add("selser", "Sanitizer: Validating that <meta> and <link> work, but only for
Microdata [[0,2,0]]", "<div itemscope=\"\">\n\tq21hg5f5s2kxzuxr\n\n<meta
itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\"
content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\"
content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link
rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\"
itemprop=\"hello\" href=\"{{SERVER}}\">\n</div>");
add("selser", "Fuzz testing: Parser13 [2]", "whfwe630sy8pvi\n{| \n|
http://a|");
add("selser", "Fuzz testing: Parser13 [1]", "{|
data-foobar=\"k83lm0w7lheyiudi\"\n| http://a||}");
add("selser", "Fuzz testing: Parser13 [[2,2]]", "{|\n<!--ot0k5hk2dibe29-->|
http://a||}");
--
To view, visit https://gerrit.wikimedia.org/r/92416
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f8255d03dce047e96b60f0dee3909fb3c96fe37
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits