A free, self-hostable news aggregator…
Fix regex search for tags (#6972)
Alexandre Alapetitedf28324c34db
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.phpindex 62d4cf9c1..50f8feea1 100644--- a/app/Models/BooleanSearch.php+++ b/app/Models/BooleanSearch.php@@ -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) ?? '';diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.phpindex 403c2c98e..8ff98a8e8 100644--- a/tests/app/Models/SearchTest.php+++ b/tests/app/Models/SearchTest.php@@ -525,6 +525,11 @@ class SearchTest extends PHPUnit\Framework\TestCase {'(NOT e.title ~ ? AND NOT e.content ~ ? )',['^ab$', '^ab$']],+ [+ '#/^a(b|c)$/im',+ "(REPLACE(REPLACE(e.tags, ' #', '#'), '#', '\n') ~* ? )",+ ['(?m)^a(b|c)$']+ ],[ // Not a regex'inurl:https://example.net/test/','(e.link LIKE ? )',