Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 0d9110f

Browse files
committed
Update path normalization
1 parent c9ef3cb commit 0d9110f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

PHPUnit_Smarty.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
7474
'PHPUnit_Smarty' => array('config', 'pdo', 'init'),
7575
);
7676

77-
private $dsMap = array('/' => array(array('\\', '/./'), '/.'),
78-
'\\' => array(array('/', '\\.\\'), '\\.'),
79-
);
8077

8178
/**
8279
* This method is called before the first test of this test class is run.
@@ -372,9 +369,9 @@ public function normalizePath($path) {
372369
if ($path[0] == '.') {
373370
$path = getcwd() . DS . $path;
374371
}
375-
$path = str_replace($this->dsMap[DS][0], DS, $path);
376-
while (strrpos($path, $this->dsMap[DS][1]) !== false) {
377-
$path = preg_replace('#([\\\/][.][\\\/])|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, $path);
372+
$path = preg_replace('#[\\\/]+([.][\\\/]+)*([.](?![.]))?#', DS, $path);
373+
while (strrpos($path, DS . '.') !== false) {
374+
$path = preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/]?)#', DS, $path);
378375
}
379376
return $path;
380377
}

0 commit comments

Comments
 (0)