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 _|_.
This commit is contained in:
LaurentGH 2025-11-18 12:00:22 +01:00 committed by GitHub
parent 7a0eef5b08
commit f9343e8079
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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));
}