Fix search expansion with backslash

fix https://github.com/FreshRSS/FreshRSS/issues/8495
This commit is contained in:
Alexandre Alapetite
2026-02-08 21:25:56 +01:00
parent f17ed2f7c8
commit d0fcedcee6
2 changed files with 7 additions and 3 deletions

View File

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

View File

@@ -975,7 +975,7 @@ final class SearchTest extends \PHPUnit\Framework\TestCase {
userdate:2025-01-01T00:00:00/2026-01-01T00:00:00
pubdate:2025-02-01T00:00:00/2026-01-01T00:00:00
date: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&d
author:/Bob/ author:"/u/Alice" author:Alice
inurl:/https/ inurl:example.net