mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-07-19 03:23:11 -04:00
Fix regex parentheses of referenced search (#6950)
fix https://github.com/FreshRSS/FreshRSS/issues/6949
This commit is contained in:
committed by
GitHub
parent
af5d8b8b48
commit
493b8d5ce2
@@ -79,7 +79,7 @@ class FreshRSS_BooleanSearch {
|
||||
if (!empty($queries[$name])) {
|
||||
$fromS[] = $matches[0][$i];
|
||||
if ($allowUserQueries) {
|
||||
$toS[] = '(' . $queries[$name] . ')';
|
||||
$toS[] = '(' . self::escapeRegexParentheses($queries[$name]) . ')';
|
||||
} else {
|
||||
$toS[] = '';
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class FreshRSS_BooleanSearch {
|
||||
if (!empty($queries[$id])) {
|
||||
$fromS[] = $matches[0][$i];
|
||||
if ($allowUserQueries) {
|
||||
$toS[] = '(' . $queries[$id] . ')';
|
||||
$toS[] = '(' . self::escapeRegexParentheses($queries[$id]) . ')';
|
||||
} else {
|
||||
$toS[] = '';
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class FreshRSS_BooleanSearch {
|
||||
* Temporarily escape parentheses used in regex expressions.
|
||||
*/
|
||||
public static function escapeRegexParentheses(string $input): string {
|
||||
return preg_replace_callback('#(?<=[\\s(:!-]|^)(?<![\\\\])/.*?(?<!\\\\)/[im]*#',
|
||||
return preg_replace_callback('#(?<=[\\s(:!-]|^)(?<![\\\\])/.+?(?<!\\\\)/[im]*#',
|
||||
fn(array $matches): string => str_replace(['(', ')'], ['\\u0028', '\\u0029'], $matches[0]),
|
||||
$input
|
||||
) ?? '';
|
||||
|
||||
Reference in New Issue
Block a user