File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
- Solarium\QueryType\Extract\Query::setFile() now supports file pointer resources
11
11
- Solarium\QueryType\Extract\Result::getFile() and getFileMetadata() to access the retrieved data for ` extractOnly=true `
12
12
13
+ ### Fixed
14
+ - Solarium\Core\Query\Helper::escapeTerm() has to quote reserved terms ` AND ` , ` OR ` , ` TO `
15
+
13
16
### Changed
14
17
- Solarium\Core\Client\Endpoint::setAuthentication() marks $password as #[ \SensitiveParameter] (PHP 8 >= 8.2.0)
15
18
- Solarium\Core\Client\Endpoint::setAuthorizationToken() marks $token as #[ \SensitiveParameter] (PHP 8 >= 8.2.0)
Original file line number Diff line number Diff line change @@ -75,9 +75,11 @@ public function __construct(QueryInterface $query = null)
75
75
*/
76
76
public function escapeTerm (string $ input ): string
77
77
{
78
- $ pattern = '/( |\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\/| \\\)/ ' ;
78
+ if (preg_match ('/(^|\s)(AND|OR|TO)($|\s)/ ' , strtoupper ($ input ), $ matches )) {
79
+ return $ this ->escapePhrase ($ input );
80
+ }
79
81
80
- return preg_replace ($ pattern , '\\\$1 ' , $ input );
82
+ return preg_replace (' /( |\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\/| \\ \)/ ' , '\\\$1 ' , $ input );
81
83
}
82
84
83
85
/**
Original file line number Diff line number Diff line change @@ -435,6 +435,17 @@ public function escapeTermProvider(): array
435
435
': ' => ['a:b ' , 'a \\:b ' ],
436
436
'/ ' => ['a/b ' , 'a \\/b ' ],
437
437
'\\' => ['a\b ' , 'a \\\b ' ],
438
+ 'and ' => ['and ' , '"and" ' ],
439
+ 'AND ' => ['AND ' , '"AND" ' ],
440
+ 'or ' => ['or ' , '"or" ' ],
441
+ 'OR ' => ['OR ' , '"OR" ' ],
442
+ 'to ' => ['to ' , '"to" ' ],
443
+ 'TO ' => ['TO ' , '"TO" ' ],
444
+ ' AnD ' => [' AnD ' , '" AnD " ' ],
445
+ 'AND or ' => ['AND or ' , '"AND or" ' ],
446
+ 'Animals and plants ' => ['Animals and plants ' , '"Animals and plants" ' ],
447
+ 'boring ' => ['boring ' , 'boring ' ],
448
+ 'Band ' => ['Band ' , 'Band ' ],
438
449
];
439
450
}
440
451
You can’t perform that action at this time.
0 commit comments