From 951b07eabc3f307a7d49fcacba649a26c0b3dde1 Mon Sep 17 00:00:00 2001 From: Frederik Bosch Date: Sat, 4 Apr 2015 12:34:51 +0200 Subject: [PATCH] Fix #3903 --- src/Composer/Util/Git.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 4888c17bd..894160d4a 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -106,8 +106,7 @@ class Git } } } elseif ( // private non-github repo that failed to authenticate - preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match) && - strpos($this->process->getErrorOutput(), 'fatal: Authentication failed') !== false + $this->isAuthenticationFailure($url, $match) ) { if (strpos($match[2], '@')) { list($authParts, $match[2]) = explode('@', $match[2], 2); @@ -155,6 +154,21 @@ class Git } } + private function isAuthenticationFailure ($url, &$match) { + if (!preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match)) { + return false; + } + + $authFailures = array('fatal: Authentication failed', 'remote error: Invalid username or password.'); + foreach ($authFailures as $authFailure) { + if (strpos($this->process->getErrorOutput(), $authFailure) !== false) { + return true; + } + } + + return false; + } + public static function cleanEnv() { if (ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {