From f9343e80794e4b09511fa12d80b882ddf0c8d98c Mon Sep 17 00:00:00 2001 From: LaurentGH <31282893+LaurentGH@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:00:22 +0100 Subject: [PATCH] Support simple logical operators in search queries tt-rss is currently supporting complex text search queries like _( one | two )_. However, simple queries containing only _!_, _(_ or _)_ were not supported. This is because the regexp only matched _&_ and _|_. --- classes/Feeds.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/classes/Feeds.php b/classes/Feeds.php index c7dccfcc6..a0d0d318a 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -2373,12 +2373,16 @@ class Feeds extends Handler_Protected { if (count($search_query_leftover) > 0) { - // if there's no joiners consider this a "simple" search and - // concatenate everything with &, otherwise don't try to mess with tsquery syntax - if (preg_match('/[&|]/', implode(' ', $search_query_leftover))) { - // Known issue: other operators such as ! and parenthesis are not detected. - // Allowing them may have side effects, so change nothing for now. - $tsquery = $pdo->quote(implode(' ', $search_query_leftover)); + /** + * If there is no logical operator, consider this a "simple" search and + * concatenate everything with &, otherwise don't try to mess with tsquery + * syntax. + * Known issue : Once the user is using at least one logical operator, he + * has to ensure his query is well formatted. No warning will be displayed. + */ + $concatenated_leftovers = implode(' ', $search_query_leftover); + if (preg_match('/[&|!()]/', $concatenated_leftovers)) { + $tsquery = $pdo->quote($concatenated_leftovers); } else { $tsquery = $pdo->quote(implode(' & ', $search_query_leftover)); }