From 3ac822d5e20f973d536c30cf5036de263bece0d7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 17 May 2016 23:02:28 +0100 Subject: [PATCH] Fix access_token param being incorrectly added on github requests after a redirection, fixes #5099 --- src/Composer/Util/RemoteFilesystem.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 133521a39..3c3326653 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -233,7 +233,10 @@ class RemoteFilesystem $origFileUrl = $fileUrl; if (isset($options['github-token'])) { - $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token']; + // only add the access_token if it is actually a github URL (in case we were redirected to S3) + if (preg_match('{^https?://([a-z0-9-]+\.)*github\.com/}', $fileUrl)) { + $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token']; + } unset($options['github-token']); }