1
0
Fork 0

Merge pull request #7752 from glaubinix/t/bitbucket-redirect

Bitbucket: fix redirect behaviour for private repositories
pull/7760/head
Jordi Boggiano 2018-10-30 11:24:14 +01:00 committed by GitHub
commit 3a98f500b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -385,15 +385,18 @@ class RemoteFilesystem
$statusCode = null; $statusCode = null;
$contentType = null; $contentType = null;
$locationHeader = null;
if (!empty($http_response_header[0])) { if (!empty($http_response_header[0])) {
$statusCode = $this->findStatusCode($http_response_header); $statusCode = $this->findStatusCode($http_response_header);
$contentType = $this->findHeaderValue($http_response_header, 'content-type'); $contentType = $this->findHeaderValue($http_response_header, 'content-type');
$locationHeader = $this->findHeaderValue($http_response_header, 'location');
} }
// check for bitbucket login page asking to authenticate // check for bitbucket login page asking to authenticate
if ($originUrl === 'bitbucket.org' if ($originUrl === 'bitbucket.org'
&& !$this->isPublicBitBucketDownload($fileUrl) && !$this->isPublicBitBucketDownload($fileUrl)
&& substr($fileUrl, -4) === '.zip' && substr($fileUrl, -4) === '.zip'
&& (!$locationHeader || substr($locationHeader, -4) !== '.zip')
&& $contentType && preg_match('{^text/html\b}i', $contentType) && $contentType && preg_match('{^text/html\b}i', $contentType)
) { ) {
$result = false; $result = false;