Skip to content

Commit e6c39e2

Browse files
committed
[BUGFIX] escapeSpecialCharacters: Add missing / to preg-pattern
The list was missing a /. Also add a list of escaped characters to the comment, since the pattern in the source is hard to read. Change-Id: Icd63253703c2cdaacc702afaebe17dfe8fff23cf Resolves: #64483 Releases: master, 3.0 Reviewed-on: http://review.typo3.org/36236 Reviewed-by: Stefan Neufeind <[email protected]> Tested-by: Stefan Neufeind <[email protected]>
1 parent 7368bf3 commit e6c39e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Classes/Query.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ public function escape($string) {
228228
*/
229229
protected function escapeSpecialCharacters($value) {
230230
// list taken from http://lucene.apache.org/core/4_4_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description
231-
// not escaping *, &&, ||, ?, -, !, + though
232-
$pattern = '/(\(|\)|\{|}|\[|]|\^|"|~|:|\\\)/';
231+
// which mentions: + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /
232+
// of which we escape: ( ) { } [ ] ^ " ~ : \ /
233+
// and explicitly don't escape: + - && || ! * ?
234+
$pattern = '/(\\(|\\)|\\{|\\}|\\[|\\]|\\^|"|~|\:|\\\\|\\/)/';
233235
$replace = '\\\$1';
234236

235237
return preg_replace($pattern, $replace, $value);

0 commit comments

Comments
 (0)