From dae27ebd5d367de034093c26d770d553f4a4e19e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 1 Feb 2026 13:06:18 +0100 Subject: [PATCH] Fix wrong search toString in case of regex-looking string (#8479) `author:'/u/Alice'` was missing its quotes during serialisation, transforming it to a regex. --- app/Models/Search.php | 2 +- tests/app/Models/SearchTest.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Models/Search.php b/app/Models/Search.php index 4d33f36b2..aca21e558 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -149,7 +149,7 @@ class FreshRSS_Search implements \Stringable { } private static function quote(string $s): string { - if (strpbrk($s, ' "\'\\') !== false || $s === '') { + if (strpbrk($s, ' "\'\\/') !== false || $s === '') { return '"' . addcslashes($s, '\\"') . '"'; } return $s; diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 09db13205..4d18606b0 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -812,6 +812,11 @@ final class SearchTest extends \PHPUnit\Framework\TestCase { '((e.title LIKE ? OR e.content LIKE ?) )', ['%https://example.net/test/%', '%https://example.net/test/%'] ], + [ // Not a regex + "author:'/u/Alice'", + "(e.author LIKE ? )", + ['%/u/Alice%'], + ], [ // Regex with literal 'or' 'intitle:/^A or B/i', '(e.title ~* ? )', @@ -972,7 +977,7 @@ final class SearchTest extends \PHPUnit\Framework\TestCase { date:2025-03-01T00:00:00/2026-01-01T00:00:00 intitle://i intitle:"g ' & d" intext://i intext:g&d - author:/Bob/ author:Alice + author:/Bob/ author:"/u/Alice" author:Alice inurl:/https/ inurl:example.net #/tag2/ #tag1 /search_regex/i "quoted search" search @@ -982,7 +987,7 @@ final class SearchTest extends \PHPUnit\Framework\TestCase { -date:P30D -intitle:/Spam/i -intitle:"'bad" -intext:/Spam/i -intext:"'bad" - -author:/Dave/i -author:Charlie + -author:/Dave/i -author:"/u/Charlie" -author:Charlie -inurl:/ftp/ -inurl:example.com -#/tag4/ -#tag3 -/not_regex/i -"not quoted" -not_search