From 60dd22d3b3916f5113954fc1472b1658c3c4245f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 22 Oct 2024 16:00:07 +0200 Subject: Allow regex parentheses (#6926) * Allow regex parentheses While waiting for a new better search parser, auto-escape parentheses in regex expressions to allow them like in `/^(ab|cd)/` * Allow escaped parenthesis in regex * A couple more tests --- tests/app/Models/SearchTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/app') diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 3092b43ca..403c2c98e 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -454,6 +454,21 @@ class SearchTest extends PHPUnit\Framework\TestCase { '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|gh)/', + '((e.title ~ ? OR e.content ~ ?) )', + ['^(ab|cd) [(] \\) (ef|gh)', '^(ab|cd) [(] \\) (ef|gh)'] + ], + [ + '!/^(ab|cd)/', + '(NOT e.title ~ ? AND NOT e.content ~ ? )', + ['^(ab|cd)', '^(ab|cd)'] + ], + [ + 'intitle:/^(ab|cd)/', + '(e.title ~ ? )', + ['^(ab|cd)'] + ], ]; } -- cgit v1.2.3