diff options
| author | 2024-10-29 08:12:30 +0100 | |
|---|---|---|
| committer | 2024-10-29 08:12:30 +0100 | |
| commit | 493b8d5ce202c1276ca0968ea80e41a666add36c (patch) | |
| tree | 813f47ebca25a6ec98b1c2b3d802ed096fb80a85 /app/Models/BooleanSearch.php | |
| parent | af5d8b8b481521c112fed801b1c8aae3b205edf7 (diff) | |
Fix regex parentheses of referenced search (#6950)
fix https://github.com/FreshRSS/FreshRSS/issues/6949
Diffstat (limited to 'app/Models/BooleanSearch.php')
| -rw-r--r-- | app/Models/BooleanSearch.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index ede705416..62d4cf9c1 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -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 ) ?? ''; |
