jenkins-bot has submitted this change and it was merged.
Change subject: #switch should not match #default as a prefix
......................................................................
#switch should not match #default as a prefix
For example, "{{#switch:x|#defaultWTF? = This is crazy}}" should not
return "This is crazy".
Bug: 67871
Change-Id: Ie3f2e6b254b9f44028156268bd8d67aa3dd1cc62
---
M ParserFunctions_body.php
M funcsParserTests.txt
2 files changed, 13 insertions(+), 2 deletions(-)
Approvals:
Brian Wolff: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ParserFunctions_body.php b/ParserFunctions_body.php
index db57dd4..05f6a93 100644
--- a/ParserFunctions_body.php
+++ b/ParserFunctions_body.php
@@ -224,7 +224,7 @@
if ( $test == $primary ) {
# Found a match, return now
return trim( $frame->expand(
$valueNode ) );
- } elseif ( $defaultFound ||
$mwDefault->matchStartAndRemove( $test ) ) {
+ } elseif ( $defaultFound ||
$mwDefault->matchStartToEnd( $test ) ) {
$default = $valueNode;
$defaultFound = false;
} # else wrong case, continue
@@ -237,7 +237,7 @@
$decodedTest = self::decodeTrimExpand(
$valueNode, $frame, $lastItem );
if ( $decodedTest == $primary ) {
$found = true;
- } elseif ( $mwDefault->matchStartAndRemove(
$decodedTest ) ) {
+ } elseif ( $mwDefault->matchStartToEnd(
$decodedTest ) ) {
$defaultFound = true;
}
}
diff --git a/funcsParserTests.txt b/funcsParserTests.txt
index 2e91939..06224ba 100644
--- a/funcsParserTests.txt
+++ b/funcsParserTests.txt
@@ -309,3 +309,14 @@
<DEF>
</p>
!! end
+
+!! test
+#switch should not match #default as a prefix
+!! input
+<{{#switch: foo | #defaultWTF? = This is crazy }}>
+<{{#switch: foo | #defaultWTF? | bar = This is crazy }}>
+!! result
+<p><>
+<>
+</p>
+!! end
--
To view, visit https://gerrit.wikimedia.org/r/145600
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3f2e6b254b9f44028156268bd8d67aa3dd1cc62
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ParserFunctions
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits