Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 681aa7b

Browse files
committed
[Finder] Escape regex special chars in location for regex searches with '^'
Previously to this commit at least GnuFindAdapter find no result in locations containing regex special chars (e.g. + or ?) and the path restriction is a regular expression with a start limitation (the regex starts with ^).
1 parent fc58264 commit 681aa7b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private function buildPathsFiltering(Command $command, $dir, array $paths, $not
216216
// Fixes 'not search' regex problems.
217217
if ($expr->isRegex()) {
218218
$regex = $expr->getRegex();
219-
$regex->prepend($regex->hasStartFlag() ? $dir.DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
219+
$regex->prepend($regex->hasStartFlag() ? preg_quote($dir).DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
220220
} else {
221221
$expr->prepend('*')->append('*');
222222
}

0 commit comments

Comments
 (0)