浏览代码

Avoid using null value as string, fixes #6134

Jordi Boggiano 8 年之前
父节点
当前提交
08fc56b38a
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/Composer/Util/RemoteFilesystem.php

+ 3 - 2
src/Composer/Util/RemoteFilesystem.php

@@ -348,7 +348,7 @@ class RemoteFilesystem
         if ($originUrl === 'bitbucket.org'
         if ($originUrl === 'bitbucket.org'
             && !$this->isPublicBitBucketDownload($fileUrl)
             && !$this->isPublicBitBucketDownload($fileUrl)
             && substr($fileUrl, -4) === '.zip'
             && substr($fileUrl, -4) === '.zip'
-            && preg_match('{^text/html\b}i', $contentType)
+            && $contentType && preg_match('{^text/html\b}i', $contentType)
         ) {
         ) {
             $result = false;
             $result = false;
             if ($this->retryAuthFailure) {
             if ($this->retryAuthFailure) {
@@ -385,7 +385,8 @@ class RemoteFilesystem
 
 
         // decode gzip
         // decode gzip
         if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
         if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
-            $decode = 'gzip' === strtolower($this->findHeaderValue($http_response_header, 'content-encoding'));
+            $contentEncoding = $this->findHeaderValue($http_response_header, 'content-encoding');
+            $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
 
 
             if ($decode) {
             if ($decode) {
                 try {
                 try {