From d97c37f103421a808fec42b00107b7df1643f4ef Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 29 Oct 2020 22:18:50 +0000 Subject: [PATCH] Zip: ignore mac osx specific folder when searching for composer.json --- src/Composer/Util/Zip.php | 5 +++++ .../Util/Fixtures/Zip/multiple_subfolders.zip | Bin 3724 -> 0 bytes tests/Composer/Test/Util/ZipTest.php | 12 ------------ 3 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 tests/Composer/Test/Util/Fixtures/Zip/multiple_subfolders.zip diff --git a/src/Composer/Util/Zip.php b/src/Composer/Util/Zip.php index 82cd34b71..3cb634eab 100644 --- a/src/Composer/Util/Zip.php +++ b/src/Composer/Util/Zip.php @@ -82,6 +82,11 @@ class Zip $name = $zip->getNameIndex($i); $dirname = dirname($name); + // ignore OSX specific resource fork folder + if (strpos($name, '__MACOSX') !== false) { + continue; + } + // handle archives with proper TOC if ($dirname === '.') { $topLevelPaths[$name] = true; diff --git a/tests/Composer/Test/Util/Fixtures/Zip/multiple_subfolders.zip b/tests/Composer/Test/Util/Fixtures/Zip/multiple_subfolders.zip deleted file mode 100644 index 5c5bc5adf86e747df57a7e1d2b7218612e3134ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3724 zcmWIWW@h1H0D<-iHv+&6D8b4gz>t=oZ>%30!Nc&j=u2E}<>$Dsj3NvHa4nZ&Z=z`7 zglS1kN``Bz0cwS56Jg*0!bvfx+Jum`>A3{Q2bbg*rGl(gDEtzqQUKBacE(1oLk0qE z?{D$3PVecfWWBH8RVp6u5E9_Hvb);s{^{_7kA)`B+_|Gk-Wu=`ir#<5)C13G)@W#$$jo}R4(|;d+)#7cr6LM|S#J72|r`=QH#f~P0>&dmo z+<9VU%fI^K)!8o+Kf8vu2sn9^UtF>0dY)v<1bLM?{9~bq^qF(Rgl#(*1H9Qe4lj+2dku^V76}HV5a*9W4LVSW z$H)6RI{ODlz(X7qS+Ed?#4WluK4fhukxW=GD7N5Mg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diff --git a/tests/Composer/Test/Util/ZipTest.php b/tests/Composer/Test/Util/ZipTest.php index 282c9b27c..2b0129bc8 100644 --- a/tests/Composer/Test/Util/ZipTest.php +++ b/tests/Composer/Test/Util/ZipTest.php @@ -125,16 +125,4 @@ class ZipTest extends TestCase $this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); } - - public function testThrowsExceptionIfMultipleComposerInSubFoldersWereFound() - { - if (!extension_loaded('zip')) { - $this->markTestSkipped('The PHP zip extension is not loaded.'); - return; - } - - $this->setExpectedException('\RuntimeException', 'Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: foo3/,__MACOSX/'); - - Zip::getComposerJson(__DIR__.'/Fixtures/Zip/multiple_subfolders.zip'); - } }