Skip to content

Commit

Permalink
Merge pull request #419 from fredden/issue-416/windows-paths-preg_quote
Browse files Browse the repository at this point in the history
Remove DIRECTORY_SEPARATOR replacement in regular expression
  • Loading branch information
Ocramius authored Sep 27, 2023
2 parents a80a012 + e2c7d31 commit e49c58b
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use function implode;
use function preg_match;
use function preg_quote;
use function preg_replace;
use function str_replace;
use function trim;

Expand Down Expand Up @@ -79,14 +78,9 @@ private function prepareBlacklistPatterns(array|null $blacklistPaths): array
$dirSep = preg_quote(DIRECTORY_SEPARATOR, '{}');

foreach ($blacklistPaths as &$path) {
$path = preg_replace(
'{' . $dirSep . '+}',
DIRECTORY_SEPARATOR,
preg_quote(
trim(str_replace('/', DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR),
'{}',
),
);
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
$path = trim($path, DIRECTORY_SEPARATOR);
$path = preg_quote($path, '{}');
$path = str_replace('\\*\\*', '.+?', $path);
$path = str_replace('\\*', '[^' . $dirSep . ']+?', $path);
}
Expand Down

0 comments on commit e49c58b

Please sign in to comment.