diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 20cfa93fc..180c441c7 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -225,12 +225,12 @@ class GitDriver extends VcsDriver // local filesystem if (Filesystem::isLocalPath($url)) { + $url = Filesystem::getPlatformPath($url); if (!is_dir($url)) { throw new \RuntimeException('Directory does not exist: '.$url); } - $process = new ProcessExecutor(); - $url = str_replace('file://', '', $url); + $process = new ProcessExecutor($io); // check whether there is a git repo in that path if ($process->execute('git tag', $output, $url) === 0) { return true; diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 7b9d1ff8c..b72058790 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -198,12 +198,12 @@ class HgDriver extends VcsDriver // local filesystem if (Filesystem::isLocalPath($url)) { + $url = Filesystem::getPlatformPath($url); if (!is_dir($url)) { throw new \RuntimeException('Directory does not exist: '.$url); } $process = new ProcessExecutor(); - $url = str_replace('file://', '', $url); // check whether there is a hg repo in that path if ($process->execute('hg summary', $output, $url) === 0) { return true; diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index 262309e67..b03f55684 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -46,7 +46,7 @@ abstract class VcsDriver implements VcsDriverInterface final public function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null) { if (Filesystem::isLocalPath($repoConfig['url'])) { - $repoConfig['url'] = preg_replace('{^file://}', '', $repoConfig['url']); + $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']); } $this->url = $repoConfig['url']; diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 6044c25d6..984f91e62 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -461,6 +461,15 @@ class Filesystem return (bool) preg_match('{^(file://|/|[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path); } + public static function getPlatformPath($path) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $path = preg_replace('{^(?:file:///([a-z])/)}i', 'file://$1:/', $path); + } + + return preg_replace('{^file://}i', '', $path); + } + protected function directorySize($directory) { $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);