From 98ba6d8bf47ff95f5bb616e23e623bd146cc85c4 Mon Sep 17 00:00:00 2001 From: Mark Ingman Date: Thu, 3 Nov 2016 17:37:14 +0000 Subject: [PATCH 1/3] Fixing empty VCS URL for file:/// paths with spaces realpath() returns FALSE for fFile paths with URL encoding like %20 for spaces. --- src/Composer/Downloader/VcsDownloader.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 8487fee25..2918d2366 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -73,6 +73,8 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa if (0 === strpos($url, $needle)) { $url = substr($url, strlen($needle)); } + // realpath() will also not understand %20 etc + $url = rawurldecode($url); $url = realpath($url); } $this->doDownload($package, $path, $url); From 98d2fcb4d8e54e062b9348791f376f6f32702436 Mon Sep 17 00:00:00 2001 From: Mark Ingman Date: Thu, 3 Nov 2016 21:38:14 +0000 Subject: [PATCH 2/3] Fixing local file VCS URLs with encoded characters realpath() returns FALSE for paths with URL encoding like %20, and decoded path needs file:/// reapplied. --- src/Composer/Downloader/VcsDownloader.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 2918d2366..9f9fc6b7c 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -67,15 +67,25 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa while ($url = array_shift($urls)) { try { if (Filesystem::isLocalPath($url)) { - # realpath() below will not understand - # url that starts with "file://" + // realpath() below will not understand + // url that starts with "file://" $needle = 'file://'; + $is_file_protocol = false; if (0 === strpos($url, $needle)) { $url = substr($url, strlen($needle)); + $is_file_protocol = true; } - // realpath() will also not understand %20 etc - $url = rawurldecode($url); + + // realpath() below will not understand %20 spaces etc. + if (false !== strpos($url, '%')) { + $url = rawurldecode($url); + } + $url = realpath($url); + + if ($is_file_protocol) { + $url = $needle . $url; + } } $this->doDownload($package, $path, $url); break; From a330d27b10122c4caf0a55d2aa85ffda5daa1053 Mon Sep 17 00:00:00 2001 From: Mark Ingman Date: Sun, 6 Nov 2016 21:32:46 +0000 Subject: [PATCH 3/3] Code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating variable name and whitespace formats inline with the project’s standards --- src/Composer/Downloader/VcsDownloader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 9f9fc6b7c..75334efed 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -70,10 +70,10 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa // realpath() below will not understand // url that starts with "file://" $needle = 'file://'; - $is_file_protocol = false; + $isFileProtocol = false; if (0 === strpos($url, $needle)) { $url = substr($url, strlen($needle)); - $is_file_protocol = true; + $isFileProtocol = true; } // realpath() below will not understand %20 spaces etc. @@ -83,9 +83,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa $url = realpath($url); - if ($is_file_protocol) { - $url = $needle . $url; - } + if ($isFileProtocol) { + $url = $needle . $url; + } } $this->doDownload($package, $path, $url); break;