From 7d0e1b1a848280eb4af98ecf14c39e2fd50020f6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 20 Sep 2024 14:01:18 +0200 Subject: Fix search with double-quote and parenthesis (#6818) Fix searches like `("test")` with a double-quote preceded by a parenthesis --- tests/app/Models/SearchTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 58eb875e0..3092b43ca 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -296,6 +296,7 @@ class SearchTest extends PHPUnit\Framework\TestCase { ['!ab OR -cd', '(!ab) OR (-cd)'], ['ab cd OR ef OR "gh ij"', '(ab cd) OR (ef) OR ("gh ij")'], ['ab (!cd)', 'ab (!cd)'], + ['"ab" (!"cd")', '"ab" (!"cd")'], ]; } @@ -321,6 +322,7 @@ class SearchTest extends PHPUnit\Framework\TestCase { ['(ab (cd OR ef OR (gh))) OR ij', '(ab ((cd) OR (ef) OR (gh))) OR (ij)'], ['(ab (!cd OR ef OR (gh))) OR ij', '(ab ((!cd) OR (ef) OR (gh))) OR (ij)'], ['(ab !(cd OR ef OR !(gh))) OR ij', '(ab !((cd) OR (ef) OR !(gh))) OR (ij)'], + ['"ab" OR (!"cd")', '("ab") OR (!"cd")'], ]; } @@ -440,6 +442,18 @@ class SearchTest extends PHPUnit\Framework\TestCase { 'OR (((e.title LIKE ? OR e.content LIKE ?) )))) OR NOT (((e.title LIKE ? OR e.content LIKE ?) ) OR ((e.title LIKE ? OR e.content LIKE ?) ))', ['%ab%', '%ab%', '%cd%', '%cd%', '%ef%', '%ef%', '%gh%', '%gh%', '%ij%', '%ij%', '%kl%', '%kl%'], ], + [ + '"ab" "cd" ("ef") intitle:"gh" !"ij" -"kl"', + '(((e.title LIKE ? OR e.content LIKE ?) AND (e.title LIKE ? OR e.content LIKE ?) )) AND (((e.title LIKE ? OR e.content LIKE ?) )) ' . + 'AND ((e.title LIKE ? AND e.title NOT LIKE ? AND e.content NOT LIKE ? AND e.title NOT LIKE ? AND e.content NOT LIKE ? ))', + ['%ab%', '%ab%', '%cd%', '%cd%', '%ef%', '%ef%', '%gh%', '%ij%', '%ij%', '%kl%', '%kl%'] + ], + [ + '"ab" "cd" ("ef") intitle:"gh" !"ij" -"kl"', + '(((e.title LIKE ? OR e.content LIKE ?) AND (e.title LIKE ? OR e.content LIKE ?) )) AND (((e.title LIKE ? OR e.content LIKE ?) )) ' . + 'AND ((e.title LIKE ? AND e.title NOT LIKE ? AND e.content NOT LIKE ? AND e.title NOT LIKE ? AND e.content NOT LIKE ? ))', + ['%ab%', '%ab%', '%cd%', '%cd%', '%ef%', '%ef%', '%gh%', '%ij%', '%ij%', '%kl%', '%kl%'] + ], ]; } -- cgit v1.2.3