A free, self-hostable news aggregator…
Fix search expansion with backslash (#8497)
Alexandre Alapetite17be48fe1c4a
diff --git a/app/Models/Search.php b/app/Models/Search.phpindex aca21e558..b1dae8cc3 100644--- a/app/Models/Search.php+++ b/app/Models/Search.php@@ -149,8 +149,12 @@ class FreshRSS_Search implements \Stringable {}private static function quote(string $s): string {- if (strpbrk($s, ' "\'\\/') !== false || $s === '') {- return '"' . addcslashes($s, '\\"') . '"';+ if (str_starts_with($s, 'S:') || str_starts_with($s, 'search:')) {+ // Discard user queries+ return $s;+ }+ if (strpbrk($s, ' "\'\\/:') !== false || $s === '') {+ return '"' . addcslashes($s, '"') . '"';}return $s;}diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.phpindex 4d18606b0..cadc2633d 100644--- a/tests/app/Models/SearchTest.php+++ b/tests/app/Models/SearchTest.php@@ -975,7 +975,7 @@ final class SearchTest extends \PHPUnit\Framework\TestCase {userdate:2025-01-01T00:00:00/2026-01-01T00:00:00pubdate:2025-02-01T00:00:00/2026-01-01T00:00:00date:2025-03-01T00:00:00/2026-01-01T00:00:00- intitle:/<Inter&sting>/i intitle:"g ' & d"+ intitle:/<Inter&sting>/i intitle:"g ' & d\\:"intext:/<Inter&sting>/i intext:g&dauthor:/Bob/ author:"/u/Alice" author:Aliceinurl:/https/ inurl:example.net