1
0
Fork 0

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

pull/2349/head
Jordi Boggiano 2013-10-19 13:38:30 +02:00
parent 17886c3b2e
commit e2671b6510
2 changed files with 3 additions and 2 deletions

View File

@ -223,11 +223,11 @@ class Filesystem
} }
$commonPath = $to; $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); $commonPath = dirname($commonPath);
} }
if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) { if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '\\' === $commonPath) {
return $to; return $to;
} }

View File

@ -106,6 +106,7 @@ class FilesystemTest extends TestCase
array('/tmp/test/.././vendor', '/tmp/test', '../test', true), 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/../..', '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('/tmp', '/tmp/../../test', '/test', true),
array('/foo/bar', '/foo/bar_vendor', '../bar_vendor', true), array('/foo/bar', '/foo/bar_vendor', '../bar_vendor', true),
array('/foo/bar_vendor', '/foo/bar', '../bar', true), array('/foo/bar_vendor', '/foo/bar', '../bar', true),