Add test and fix patch for #2304, refs #2341

main
Jordi Boggiano 11 years ago
parent 17886c3b2e
commit e2671b6510

@ -223,11 +223,11 @@ class Filesystem
}
$commonPath = $to;
while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '\\' !== $commonPath) {
$commonPath = dirname($commonPath);
}
if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '\\' === $commonPath) {
return $to;
}

@ -106,6 +106,7 @@ class FilesystemTest extends TestCase
array('/tmp/test/.././vendor', '/tmp/test', '../test', true),
array('C:/Temp', 'c:\Temp\..\..\test', "../test", true),
array('C:/Temp/../..', 'c:\Temp\..\..\test', "./test", true),
array('C:/Temp/../..', 'D:\Temp\..\..\test', "d:/test", true),
array('/tmp', '/tmp/../../test', '/test', true),
array('/foo/bar', '/foo/bar_vendor', '../bar_vendor', true),
array('/foo/bar_vendor', '/foo/bar', '../bar', true),

Loading…
Cancel
Save