浏览代码

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

Jordi Boggiano 11 年之前
父节点
当前提交
e2671b6510
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 2
      src/Composer/Util/Filesystem.php
  2. 1 0
      tests/Composer/Test/Util/FilesystemTest.php

+ 2 - 2
src/Composer/Util/Filesystem.php

@@ -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;
         }
         }
 
 

+ 1 - 0
tests/Composer/Test/Util/FilesystemTest.php

@@ -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),