From f2e026e9352e755e68b691057eac1e8075747667 Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:41:07 +0200 Subject: [PATCH 1/6] #11917 fix: Possibility to handle long URLs --- src/Composer/Downloader/GitDownloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 0840219d0fe6..8d4c5bb0ca85 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -67,7 +67,7 @@ protected function doDownload(PackageInterface $package, string $path, string $u GitUtil::cleanEnv(); - $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/'; + $cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/'; $gitVersion = GitUtil::getVersion($this->process); // --dissociate option is only available since git 2.3.0-rc0 From cb5cd2269b14ca45368e85afb74813b2227db60f Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:49:17 +0200 Subject: [PATCH 2/6] #11917 fix: Possibility to handle long URLs --- src/Composer/Downloader/GitDownloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 8d4c5bb0ca85..b3e13a7487bd 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -92,7 +92,7 @@ protected function doInstall(PackageInterface $package, string $path, string $ur { GitUtil::cleanEnv(); $path = $this->normalizePath($path); - $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/'; + $cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/'; $ref = $package->getSourceReference(); $flag = Platform::isWindows() ? '/D ' : ''; @@ -161,7 +161,7 @@ protected function doUpdate(PackageInterface $initial, PackageInterface $target, throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } - $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/'; + $cachePath = $this->config->get('cache-vcs-dir').'/'.md5($url).'/'; $ref = $target->getSourceReference(); if (!empty($this->cachedPackages[$target->getId()][$ref])) { From c783e801c6bd40ae2165937dfe0b627a927f67d2 Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:10:01 +0200 Subject: [PATCH 3/6] #11917 fix: Possibility to handle long URLs --- tests/Composer/Test/Downloader/GitDownloaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index 5411767e56b3..a1393ed2e2aa 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -155,7 +155,7 @@ public function testDownloadWithCache(): void $config = new Config; $this->setupConfig($config); - $cachePath = $config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', 'https://example.com/composer/composer').'/'; + $cachePath = $config->get('cache-vcs-dir').'/'.md5('https://example.com/composer/composer').'/'; $filesystem = new \Composer\Util\Filesystem; $filesystem->removeDirectory($cachePath); From c7b91fc19f675dfa59c59fc767fc08f7ae62a95f Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:35:20 +0200 Subject: [PATCH 4/6] #11917 fix: Possibility to handle long URLs --- src/Composer/Repository/Vcs/GitDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 75ede6910d04..171200c331eb 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -52,7 +52,7 @@ public function initialize(): void throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled'); } - $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', $this->url) . '/'; + $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . md5($this->url) . '/'; GitUtil::cleanEnv(); From 47a5a4578455ceaed0dc97b5c618705d54948209 Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:39:40 +0200 Subject: [PATCH 5/6] #11917 fix: Possibility to handle long URLs --- tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index aa454e8946d5..791d90545be4 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -304,7 +304,7 @@ public function testPrivateRepositoryNoInteraction(): void $process = $this->getProcessExecutorMock(); $process->expects([ ['cmd' => 'git config github.accesstoken', 'return' => 1], - 'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/git-github.com-composer-packagist.git/'), + 'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/'.md5($repoUrl).'/'), [ 'cmd' => 'git show-ref --tags --dereference', 'stdout' => $sha.' refs/tags/'.$identifier, From 8fff33acda10fef54231d2e89dc3d3e1bf79c74a Mon Sep 17 00:00:00 2001 From: p24-max <106059119+p24-max@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:43:43 +0200 Subject: [PATCH 6/6] #11917 fix: Possibility to handle long URLs --- tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 791d90545be4..28cb4111accb 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -304,7 +304,7 @@ public function testPrivateRepositoryNoInteraction(): void $process = $this->getProcessExecutorMock(); $process->expects([ ['cmd' => 'git config github.accesstoken', 'return' => 1], - 'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/'.md5($repoUrl).'/'), + 'git clone --mirror -- '.ProcessExecutor::escape($repoSshUrl).' '.ProcessExecutor::escape($this->config->get('cache-vcs-dir').'/'.md5($repoSshUrl).'/'), [ 'cmd' => 'git show-ref --tags --dereference', 'stdout' => $sha.' refs/tags/'.$identifier,