1
0
Fork 0

Merge pull request #9379 from glaubinix/f/zip-util

Zip: ignore mac osx specific folder when searching for composer.json
pull/9384/head
Jordi Boggiano 2020-10-30 10:48:31 +01:00 committed by GitHub
commit 41daf69c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 12 deletions

View File

@ -82,6 +82,11 @@ class Zip
$name = $zip->getNameIndex($i); $name = $zip->getNameIndex($i);
$dirname = dirname($name); $dirname = dirname($name);
// ignore OSX specific resource fork folder
if (strpos($name, '__MACOSX') !== false) {
continue;
}
// handle archives with proper TOC // handle archives with proper TOC
if ($dirname === '.') { if ($dirname === '.') {
$topLevelPaths[$name] = true; $topLevelPaths[$name] = true;

View File

@ -125,16 +125,4 @@ class ZipTest extends TestCase
$this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result); $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');
}
} }