From 1cda8e1ef0b36e62afb9aa23a4c38dfcca4bca3b Mon Sep 17 00:00:00 2001 From: Cameron Eagans Date: Fri, 16 Dec 2016 18:11:06 -0700 Subject: [PATCH] Allow use of parent directories in PathDownloader when not mirroring the path --- src/Composer/Downloader/PathDownloader.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index cde32f4a6..f392c0125 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -45,13 +45,6 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter )); } - if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) { - throw new \RuntimeException(sprintf( - 'Package %s cannot install to "%s" inside its source at "%s"', - $package->getName(), realpath($path), $realUrl - )); - } - // Get the transport options with default values $transportOptions = $package->getTransportOptions() + array('symlink' => null); @@ -72,6 +65,13 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter $allowedStrategies = array(self::STRATEGY_MIRROR); } + if ($currentStrategy != self::STRATEGY_MIRROR && strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) { + throw new \RuntimeException(sprintf( + 'Package %s cannot install to "%s" inside its source at "%s"', + $package->getName(), realpath($path), $realUrl + )); + } + $fileSystem = new Filesystem(); $this->filesystem->removeDirectory($path);