Skip to content

Commit

Permalink
Merge pull request #1310 from Fossil01/master
Browse files Browse the repository at this point in the history
Add more string escape/replace methods for search
  • Loading branch information
DariusIII authored Apr 9, 2023
2 parents 3761c71 + 4893bf6 commit 25d07de
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Blacklight/ManticoreSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,18 @@ public function deleteRelease(array $identifiers): void
*/
public static function escapeString(string $string): string
{
$from = ['\\', '(', ')', '@', '~', '"', '&', '/', '$', '=', "'"];
$to = ['\\\\', '\(', '\)', '\@', '\~', '\"', '\&', '\/', '\$', '\=', "\'"];
if ($string === '*') {
return '';
}

$from = ['\\', '(', ')', '@', '~', '"', '&', '/', '$', '=', "'", '--', '[', ']'];
$to = ['\\\\', '\(', '\)', '\@', '\~', '\"', '\&', '\/', '\$', '\=', "\', '\--", '\[', '\]'];

$string = str_replace($from, $to, $string);
$string = Str::replaceLast('!', '', $string);
$string = Str::replaceLast('-', '', $string);

return str_replace($from, $to, $string);
return $string;
}

public function updateRelease(int|string $releaseID): void
Expand Down

0 comments on commit 25d07de

Please sign in to comment.