From a20ee1a448337b8de157110a6cbe6da029a2c669 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 12 Jan 2021 16:31:36 +0100 Subject: [PATCH] Avoid matching .git suffix if present in private github URLs, fixes #9590 --- src/Composer/Util/Git.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 4eafc24e0..ed6da6c80 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -101,7 +101,7 @@ class Git $errorMsg = $this->process->getErrorOutput(); // private github repository without ssh key access, try https with auth if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match) - || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match) + || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}', $url, $match) ) { if (!$this->io->hasAuthentication($match[1])) { $gitHubUtil = new GitHub($this->io, $this->config, $this->process); @@ -122,7 +122,7 @@ class Git $errorMsg = $this->process->getErrorOutput(); } - } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) { //bitbucket oauth + } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(?:\.git)?$}U', $url, $match)) { //bitbucket oauth $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process); if (!$this->io->hasAuthentication($match[1])) {