1
0
Fork 0

Merge branch '1.0'

pull/5224/head
Jordi Boggiano 2016-04-19 15:44:38 +01:00
commit 31dcc0bdea
3 changed files with 20 additions and 2 deletions

View File

@ -76,7 +76,7 @@ class GzipDownloader extends ArchiveDownloader
$archiveFile = gzopen($file, 'rb');
$targetFile = fopen($targetFilepath, 'wb');
while ($string = gzread($archiveFile, 4096)) {
fwrite($targetFile, $string, strlen($string));
fwrite($targetFile, $string, Platform::strlen($string));
}
gzclose($archiveFile);
fclose($targetFile);

View File

@ -26,4 +26,22 @@ class Platform
{
return defined('PHP_WINDOWS_VERSION_BUILD');
}
/**
* @param string $str
* @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
*/
public static function strlen($str)
{
static $useMbString = null;
if (null === $useMbString) {
$useMbString = function_exists('mb_strlen') && ini_get('mbstring.func_overload');
}
if ($useMbString) {
return mb_strlen($str, '8bit');
}
return strlen($str);
}
}

View File

@ -279,7 +279,7 @@ class RemoteFilesystem
try {
$result = file_get_contents($fileUrl, false, $ctx);
if ($this->bytesMax && strlen($result) < $this->bytesMax) {
if ($this->bytesMax && Platform::strlen($result) < $this->bytesMax) {
// alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP
throw new TransportException('Content-Length mismatch');
}