From e2671b6510f994cbcae9642be9bdc74c00f25f5b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 19 Oct 2013 13:38:30 +0200 Subject: [PATCH] Add test and fix patch for #2304, refs #2341 --- src/Composer/Util/Filesystem.php | 4 ++-- tests/Composer/Test/Util/FilesystemTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index fe7b90bbd..15ce1cebd 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -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; } diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 29e7d8c62..c74e84a5f 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -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),