Skip to content

Commit

Permalink
Compare cleaned pageid case-insensitive in search (#2667)
Browse files Browse the repository at this point in the history
* add tests for #2613
* compare cleaned pageid case-insensitive in search
* add test for utf8 capital letters in search - Thanks @micgro42 for pointing out German and Russian that have these characters!
* use utf8_strtolower instead of strtolower
  • Loading branch information
phy25 committed Feb 21, 2019
2 parents 79620db + e180e45 commit 0118dd1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions _test/tests/inc/Ui/Search_createPagenameFromQuery.test.php
Expand Up @@ -93,6 +93,38 @@ function dataProvider()
':wiki:foo',
'pageid with colons should result in that pageid',
],
[
[
'query' => 'WiKi:Foo',
'parsed_str' => '((W+:wiki)AND(W+:foo))',
'parsed_ary' => [0 => 'W+:wiki', 1 => 'W+:foo', 2 => 'AND',],
'words' => [0 => 'wiki', 1 => 'foo',],
'highlight' => [0 => 'wiki', 1 => 'foo',],
'and' => [0 => 'wiki', 1 => 'foo',],
'phrases' => [],
'ns' => [],
'notns' => [],
'not' => [],
],
':wiki:foo',
'uppercased pageid with colons should result in clean pageid',
],
[
[
'query' => 'Бб:Гг:Rr',
'parsed_str' => '((W+:бб)AND(W+:гг)AND(W+:rr))',
'parsed_ary' => ['W+:бб', 'AND', 'W+:гг', 'AND', 'W+:rr', 'AND'],
'words' => ["бб", "гг", "rr"],
'highlight' => ["бб", "гг", "rr"],
'and' => ["бб", "гг", "rr"],
'phrases' => [],
'ns' => [],
'notns' => [],
'not' => [],
],
':бб:гг:rr',
'uppercased utf-8 pageid with colons should result in clean pageid',
],
[
[
'query' => '"wiki:foo"',
Expand Down
4 changes: 2 additions & 2 deletions inc/Ui/Search.php
Expand Up @@ -498,8 +498,8 @@ protected function getSearchIntroHTML($query)
*/
public function createPagenameFromQuery($parsedQuery)
{
$cleanedQuery = cleanID($parsedQuery['query']);
if ($cleanedQuery === $parsedQuery['query']) {
$cleanedQuery = cleanID($parsedQuery['query']); // already strtolowered
if ($cleanedQuery === utf8_strtolower($parsedQuery['query'])) {
return ':' . $cleanedQuery;
}
$pagename = '';
Expand Down

0 comments on commit 0118dd1

Please sign in to comment.