Skip to content

Commit

Permalink
Fix inside quotes incorrectly trimmed out
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Nov 8, 2023
1 parent e6ce7e4 commit d9b299f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Libraries/Search/BeatmapsetQueryParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ private static function makeIntRangeOption($operator, $value)
}
}

private static function makeTextOption($operator, $value)
private static function makeTextOption(string $operator, string $value): ?string
{
if ($operator === '=') {
return presence(trim($value, '"'));
}
return $operator === '='
? presence(preg_replace('/^"(.*)"$/', '$1', $value))
: null;
}

private static function statePrefixSearch($value): ?int
Expand Down
1 change: 1 addition & 0 deletions tests/Libraries/Search/BeatmapsetQueryParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function queryDataProvider()
['find me songs by artist=singer please', ['keywords' => 'find me songs by please', 'options' => ['artist' => 'singer']]],
['really like artist="name with space" yes', ['keywords' => 'really like yes', 'options' => ['artist' => 'name with space']]],
['weird artist=double"quote', ['keywords' => 'weird', 'options' => ['artist' => 'double"quote']]],
['weird artist="nested "quote"" thing', ['keywords' => 'weird thing', 'options' => ['artist' => 'nested "quote"']]],
['artist=><something', ['keywords' => null, 'options' => ['artist' => '><something']]],
['unrecognised=keyword', ['keywords' => 'unrecognised=keyword', 'options' => []]],
['cs=nope', ['keywords' => 'cs=nope', 'options' => []]],
Expand Down

0 comments on commit d9b299f

Please sign in to comment.