https://github.com/FreshRSS/FreshRSS/issues/6949#issuecomment-2452363378
@@ -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
) ?? '';
@@ -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 ? )',