From 8b8df013361c1d57caabc36f9e9efb516a177558 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Fri, 26 Oct 2018 15:48:18 +0200 Subject: [PATCH] Bitbucket: fix redirect behaviour --- src/Composer/Util/RemoteFilesystem.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index dc2b33089..def4091a6 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -385,15 +385,18 @@ class RemoteFilesystem $statusCode = null; $contentType = null; + $locationHeader = null; if (!empty($http_response_header[0])) { $statusCode = $this->findStatusCode($http_response_header); $contentType = $this->findHeaderValue($http_response_header, 'content-type'); + $locationHeader = $this->findHeaderValue($http_response_header, 'location'); } // check for bitbucket login page asking to authenticate if ($originUrl === 'bitbucket.org' && !$this->isPublicBitBucketDownload($fileUrl) && substr($fileUrl, -4) === '.zip' + && (!$locationHeader || substr($locationHeader, -4) !== '.zip') && $contentType && preg_match('{^text/html\b}i', $contentType) ) { $result = false;