From c9aa9c0d2fb2280f6ebda68b175f920a155e69b9 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 30 Mar 2018 18:37:56 +0200 Subject: [PATCH] Fix usage of svn user-provided credentials, fixes #7114, closes #7228 --- src/Composer/Util/Svn.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index 5df04e8c7..898fadce0 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -107,9 +107,7 @@ class Svn // Ensure we are allowed to use this URL by config $this->config->prohibitUrlByConfig($url, $this->io); - $svnCommand = $this->getCommand($command, $url, $path); - - return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose); + return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose); } /** @@ -126,18 +124,15 @@ class Svn */ public function executeLocal($command, $path, $cwd = null, $verbose = false) { - $svnCommand = sprintf('%s %s%s %s', - $command, - '--non-interactive ', - $this->getCredentialString(), - ProcessExecutor::escape($path) - ); - - return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose); + // A local command has no remote url + return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose); } - private function executeWithAuthRetry($command, $cwd, $path, $verbose) + private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose) { + // Regenerate the command at each try, to use the newly user-provided credentials + $command = $this->getCommand($svnCommand, $url, $path); + $output = null; $io = $this->io; $handler = function ($type, $buffer) use (&$output, $io, $verbose) { @@ -175,7 +170,7 @@ class Svn // try to authenticate if maximum quantity of tries not reached if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) { // restart the process - return $this->executeWithAuthRetry($command, $cwd, $path, $verbose); + return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose); } throw new \RuntimeException(