mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Escape some of the characters in query string
This commit is contained in:
@@ -98,8 +98,8 @@ class ManticoreSearch
|
|||||||
*/
|
*/
|
||||||
public static function escapeString(string $string): string
|
public static function escapeString(string $string): string
|
||||||
{
|
{
|
||||||
$from = ['\\', '(', ')', '|', '-', '!', '@', '~', '"', '&', '/', '^', '$', '=', "'"];
|
$from = ['\\', '(', ')', '@', '~', '"', '&', '/', '$', '=', "'"];
|
||||||
$to = ['\\\\', '\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/', '\^', '\$', '\=', "\'"];
|
$to = ['\\\\', '\(', '\)', '\@', '\~', '\"', '\&', '\/', '\$', '\=', "\'"];
|
||||||
|
|
||||||
return str_replace($from, $to, $string);
|
return str_replace($from, $to, $string);
|
||||||
}
|
}
|
||||||
@@ -186,14 +186,14 @@ class ManticoreSearch
|
|||||||
{
|
{
|
||||||
$resultId = [];
|
$resultId = [];
|
||||||
$resultData = [];
|
$resultData = [];
|
||||||
$query = $this->search->setIndex($rt_index)->option('boolean_simplify', 1)->option('ranker', 'sph04')->option('sort_method', 'pq')->maxMatches(10000)->limit(10000)->sort('id', 'desc')->stripBadUtf8(true)->trackScores(true);
|
$query = $this->search->setIndex($rt_index)->option('ranker', 'sph04')->option('sort_method', 'pq')->maxMatches(10000)->limit(10000)->sort('id', 'desc')->stripBadUtf8(true)->trackScores(true);
|
||||||
if (! empty($searchArray)) {
|
if (! empty($searchArray)) {
|
||||||
foreach ($searchArray as $key => $value) {
|
foreach ($searchArray as $key => $value) {
|
||||||
$query->search('@@relaxed @'.$key.' '.$value);
|
$query->search('@@relaxed @'.$key.' '.self::escapeString($value));
|
||||||
}
|
}
|
||||||
} elseif (! empty($searchString)) {
|
} elseif (! empty($searchString)) {
|
||||||
$searchColumns = ! empty($column) ? '@'.implode('', $column) : '';
|
$searchColumns = ! empty($column) ? '@'.implode('', $column) : '';
|
||||||
$query->search('@@relaxed'.$searchColumns.' '.$searchString);
|
$query->search('@@relaxed'.$searchColumns.' '.self::escapeString($searchString));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user