diff --git a/app/Libraries/Search/BeatmapsetQueryParser.php b/app/Libraries/Search/BeatmapsetQueryParser.php index 4f948e0556a..9570b65571f 100644 --- a/app/Libraries/Search/BeatmapsetQueryParser.php +++ b/app/Libraries/Search/BeatmapsetQueryParser.php @@ -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 diff --git a/tests/Libraries/Search/BeatmapsetQueryParserTest.php b/tests/Libraries/Search/BeatmapsetQueryParserTest.php index a51d7f924d6..d2883bb4cca 100644 --- a/tests/Libraries/Search/BeatmapsetQueryParserTest.php +++ b/tests/Libraries/Search/BeatmapsetQueryParserTest.php @@ -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=> null, 'options' => ['artist' => '> 'unrecognised=keyword', 'options' => []]], ['cs=nope', ['keywords' => 'cs=nope', 'options' => []]],