Quellcode durchsuchen

Fix search expansion with backslash (#8497)

fix https://github.com/FreshRSS/FreshRSS/issues/8495
Alexandre Alapetite vor 1 Monat
Ursprung
Commit
17be48fe1c
2 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen
  1. 6 2
      app/Models/Search.php
  2. 1 1
      tests/app/Models/SearchTest.php

+ 6 - 2
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;
 	}

+ 1 - 1
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: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