From 33828b38dff2435d0ce6a46887ba7c66f5015a1d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 7 Feb 2013 11:36:49 +0100 Subject: [PATCH] Use a saner file name for package archives --- src/Composer/Package/Archiver/ArchiveManager.php | 5 +++-- tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index ff8e2da95..5da4d89ae 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -75,12 +75,13 @@ class ArchiveManager // Directory used to download the sources $filesystem = new Filesystem(); - $packageName = $package->getUniqueName(); + $packageName = preg_replace('#[^a-z0-9-_.]#i', '-', $package->getPrettyString()); $sourcePath = sys_get_temp_dir().'/composer_archiver/'.$packageName; $filesystem->ensureDirectoryExists($sourcePath); // Archive filename - $target = $targetDir.'/'.$packageName.'.'.$format; + $filesystem->ensureDirectoryExists($targetDir); + $target = realpath($targetDir).'/'.$packageName.'.'.$format; $filesystem->ensureDirectoryExists(dirname($target)); // Download sources diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index f1eb73be1..54caa0186 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -63,7 +63,7 @@ class ArchiveManagerTest extends ArchiverTest protected function getTargetName(PackageInterface $package, $format) { - $packageName = $package->getUniqueName(); + $packageName = preg_replace('#[^a-z0-9-_.]#i', '-', $package->getPrettyString()); $target = $this->targetDir.'/'.$packageName.'.'.$format; return $target;