jenkins-bot has submitted this change and it was merged.
Change subject: Support escaped quotes in filters
......................................................................
Support escaped quotes in filters
Adds support for escaped quotes in filters link incategory and intitle. This
is important
because Hebrew uses double quotes in words so Hebrew Wikipedia uses them in
the names of categories that you might want to use with incategory or intitle
or linksto or whatever.
Bug: 71123
Change-Id: Id0cffb88a99f473ccb36afbe379b18150206abe7
---
M includes/Searcher.php
M tests/browser/features/incategory.feature
M tests/browser/features/support/hooks.rb
3 files changed, 7 insertions(+), 2 deletions(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Searcher.php b/includes/Searcher.php
index bd78012..8934a73 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -461,11 +461,12 @@
$escaper = $this->escaper;
$fuzzyQuery = $this->fuzzyQuery;
$this->extractSpecialSyntaxFromTerm(
- '/(?<key>[a-z\\-]{7,15}):\s*(?<value>"[^"]+"|[^ "]+)
?/',
+
'/(?<key>[a-z\\-]{7,15}):\s*(?<value>"(?:[^"]|(?:\"))+"|[^ "]+) ?/',
function ( $matches ) use ( $searcher, $escaper,
&$filters, &$notFilters, &$boostTemplates,
&$searchContainedSyntax, &$fuzzyQuery )
{
$key = $matches['key'];
$value = $matches['value']; // Note that if
the user supplied quotes they are not removed
+ $value = str_replace( '\"', '"', $value );
$filterDestination = &$filters;
$keepText = true;
if ( $key[ 0 ] === '-' ) {
diff --git a/tests/browser/features/incategory.feature
b/tests/browser/features/incategory.feature
index dd47f2a..44e57a6 100644
--- a/tests/browser/features/incategory.feature
+++ b/tests/browser/features/incategory.feature
@@ -28,6 +28,10 @@
When I search for incategory:"Categorywith Twowords"
Then Two Words is the first search result
+ Scenario: incategory can find categories containing quotes if the quote is
escaped
+ When I search for incategory:"Categorywith \" Quote"
+ Then Two Words is the first search result
+
Scenario: incategory works with can find two word categories with spaces
When I search for incategory:Categorywith_Twowords
Then Two Words is the first search result
diff --git a/tests/browser/features/support/hooks.rb
b/tests/browser/features/support/hooks.rb
index e8ca05f..0207b02 100644
--- a/tests/browser/features/support/hooks.rb
+++ b/tests/browser/features/support/hooks.rb
@@ -9,7 +9,7 @@
And a page named Links To Catapult exists with contents [[Catapult]]
And a page named Catapult exists with contents ♙ asdf
[[Category:Weaponry]]
And a page named Amazing Catapult exists with contents test [[Catapult]]
[[Category:Weaponry]]
- And a page named Two Words exists with contents ffnonesenseword catapult
{{Template_Test}} anotherword [[Category:TwoWords]] [[Category:Categorywith
Twowords]]
+ And a page named Two Words exists with contents ffnonesenseword catapult
{{Template_Test}} anotherword [[Category:TwoWords]] [[Category:Categorywith
Twowords]] [[Category:Categorywith " Quote]]
And a page named AlphaBeta exists with contents [[Category:Alpha]]
[[Category:Beta]]
And a page named IHaveATwoWordCategory exists with contents
[[Category:CategoryWith ASpace]]
And a page named वाङ्मय exists
--
To view, visit https://gerrit.wikimedia.org/r/161986
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id0cffb88a99f473ccb36afbe379b18150206abe7
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits