diff options
| author | 2023-01-09 12:59:09 +0100 | |
|---|---|---|
| committer | 2023-01-09 12:59:09 +0100 | |
| commit | 3fb8ab8eb5c88042320bbe006825b21f5a8f21de (patch) | |
| tree | 3c7412d44bae45f4678cb5db3192ab22db58f2f7 /app/Models/BooleanSearch.php | |
| parent | b5a418ec1618cb1a058aee3dd47baa63562c9194 (diff) | |
Handling of parentheses as special characters in searches (#4989)
#fix https://github.com/FreshRSS/FreshRSS/issues/4987
Diffstat (limited to 'app/Models/BooleanSearch.php')
| -rw-r--r-- | app/Models/BooleanSearch.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index b1c7bbd3b..279040a5a 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -118,8 +118,9 @@ class FreshRSS_BooleanSearch { $nextOperator = 'AND'; while ($i < $length) { $c = $input[$i]; + $backslashed = $i >= 1 ? $input[$i - 1] === '\\' : false; - if ($c === '(') { + if ($c === '(' && !$backslashed) { $hasParenthesis = true; $before = trim($before); @@ -164,11 +165,12 @@ class FreshRSS_BooleanSearch { $i++; while ($i < $length) { $c = $input[$i]; - if ($c === '(') { + $backslashed = $input[$i - 1] === '\\'; + if ($c === '(' && !$backslashed) { // One nested level deeper $parentheses++; $sub .= $c; - } elseif ($c === ')') { + } elseif ($c === ')' && !$backslashed) { $parentheses--; if ($parentheses === 0) { // Found the matching closing parenthesis |
