瀏覽代碼

Warn identical names w/ different capitalization - extract zip archive

Warn about identical names with different capitalization on zip archive
extract failure (Not a directory)

Issue #5938
AjiYakin 8 年之前
父節點
當前提交
8858b27ced
共有 2 個文件被更改,包括 24 次插入0 次删除
  1. 2 0
      src/Composer/Downloader/ZipDownloader.php
  2. 22 0
      tests/Composer/Test/Downloader/ZipDownloaderTest.php

+ 2 - 0
src/Composer/Downloader/ZipDownloader.php

@@ -156,6 +156,8 @@ class ZipDownloader extends ArchiveDownloader
             } else {
             } else {
                 $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
                 $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
             }
             }
+        } catch (\ErrorException $ex) {
+            $processError = new \ErrorException('Archive may contain identical directory or file name with different capitalization (fails on case insensitive filesystems)');
         } catch (\Exception $e) {
         } catch (\Exception $e) {
             $processError = $e;
             $processError = $e;
         }
         }

+ 22 - 0
tests/Composer/Test/Downloader/ZipDownloaderTest.php

@@ -127,6 +127,28 @@ class ZipDownloaderTest extends TestCase
         $downloader->extract('testfile.zip', 'vendor/dir');
         $downloader->extract('testfile.zip', 'vendor/dir');
     }
     }
 
 
+    /**
+     * @expectedException \ErrorException
+     * @expectedExceptionMessage Archive may contain identical directory or file name with different capitalization (fails on case insensitive filesystems)
+     */
+    public function testZipArchiveExtractOnlyFailed()
+    {
+        $this->setPrivateProperty('hasSystemUnzip', false);
+        $this->setPrivateProperty('hasZipArchive', true);
+        $downloader = new MockedZipDownloader($this->io, $this->config);
+
+        $zipArchive = $this->getMock('ZipArchive');
+        $zipArchive->expects($this->at(0))
+            ->method('open')
+            ->will($this->returnValue(true));
+        $zipArchive->expects($this->at(1))
+            ->method('extractTo')
+            ->will($this->throwException(new \ErrorException('Not a directory')));
+
+        $this->setPrivateProperty('zipArchiveObject', $zipArchive, $downloader);
+        $downloader->extract('testfile.zip', 'vendor/dir');
+    }
+
     /**
     /**
      * @group only
      * @group only
      */
      */