updated php-archive lib. fixes #2361

This commit is contained in:
Andreas Gohr 2018-05-01 10:10:27 +02:00
parent 10bf5c9334
commit ddb94cf031
6 changed files with 94 additions and 72 deletions

17
composer.lock generated
View File

@ -389,23 +389,26 @@
},
{
"name": "splitbrain/php-archive",
"version": "1.0.9",
"version": "1.0.10",
"source": {
"type": "git",
"url": "https://github.com/splitbrain/php-archive.git",
"reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76"
"reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/splitbrain/php-archive/zipball/2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
"reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
"url": "https://api.github.com/repos/splitbrain/php-archive/zipball/a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
"reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "4.5.*"
"ext-bz2": "*",
"ext-zip": "*",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^4.8"
},
"suggest": {
"ext-iconv": "Used for proper filename encode handling",
@ -436,7 +439,7 @@
"unzip",
"zip"
],
"time": "2017-06-11T06:11:38+00:00"
"time": "2018-05-01T08:03:56+00:00"
},
{
"name": "splitbrain/php-cli",

View File

@ -188,59 +188,6 @@
"description": "lesserphp is a compiler for LESS written in PHP based on leafo's lessphp.",
"homepage": "http://leafo.net/lessphp/"
},
{
"name": "splitbrain/php-archive",
"version": "1.0.9",
"version_normalized": "1.0.9.0",
"source": {
"type": "git",
"url": "https://github.com/splitbrain/php-archive.git",
"reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/splitbrain/php-archive/zipball/2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
"reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.5.*"
},
"suggest": {
"ext-iconv": "Used for proper filename encode handling",
"ext-mbstring": "Can be used alternatively for handling filename encoding"
},
"time": "2017-06-11T06:11:38+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"splitbrain\\PHPArchive\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Gohr",
"email": "andi@splitbrain.org"
}
],
"description": "Pure-PHP implementation to read and write TAR and ZIP archives",
"keywords": [
"archive",
"extract",
"tar",
"unpack",
"unzip",
"zip"
]
},
{
"name": "paragonie/random_compat",
"version": "v2.0.12",
@ -499,5 +446,61 @@
"x.509",
"x509"
]
},
{
"name": "splitbrain/php-archive",
"version": "1.0.10",
"version_normalized": "1.0.10.0",
"source": {
"type": "git",
"url": "https://github.com/splitbrain/php-archive.git",
"reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/splitbrain/php-archive/zipball/a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
"reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
"shasum": ""
},
"require": {
"php": ">=5.4"
},
"require-dev": {
"ext-bz2": "*",
"ext-zip": "*",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^4.8"
},
"suggest": {
"ext-iconv": "Used for proper filename encode handling",
"ext-mbstring": "Can be used alternatively for handling filename encoding"
},
"time": "2018-05-01T08:03:56+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"splitbrain\\PHPArchive\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Gohr",
"email": "andi@splitbrain.org"
}
],
"description": "Pure-PHP implementation to read and write TAR and ZIP archives",
"keywords": [
"archive",
"extract",
"tar",
"unpack",
"unzip",
"zip"
]
}
]

View File

@ -11,7 +11,7 @@
"license": "MIT",
"require": {
"php": ">=5.3.0"
"php": ">=5.4"
},
"suggest": {
@ -20,12 +20,21 @@
},
"require-dev": {
"phpunit/phpunit": "4.5.*"
"phpunit/phpunit": "^4.8",
"mikey179/vfsStream": "^1.6",
"ext-zip": "*",
"ext-bz2": "*"
},
"autoload": {
"psr-4": {
"splitbrain\\PHPArchive\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"splitbrain\\PHPArchive\\": "tests"
}
}
}

View File

@ -14,4 +14,9 @@
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
<filter>
<whitelist processUncoveredFilesFromWhitelist="false">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -164,7 +164,7 @@ class Tar extends Archive
// extract data
if (!$fileinfo->getIsdir()) {
$fp = fopen($output, "wb");
$fp = @fopen($output, "wb");
if (!$fp) {
throw new ArchiveIOException('Could not open file for writing: '.$output);
}
@ -245,7 +245,7 @@ class Tar extends Archive
throw new ArchiveIOException('Archive has been closed, files can no longer be added');
}
$fp = fopen($file, 'rb');
$fp = @fopen($file, 'rb');
if (!$fp) {
throw new ArchiveIOException('Could not open file for reading: '.$file);
}
@ -379,7 +379,7 @@ class Tar extends Archive
$this->setCompression($this->complevel, $this->filetype($file));
}
if (!file_put_contents($file, $this->getArchive())) {
if (!@file_put_contents($file, $this->getArchive())) {
throw new ArchiveIOException('Could not write to file: '.$file);
}
}
@ -433,7 +433,7 @@ class Tar extends Archive
*
* @param int $bytes seek to this position
*/
function skipbytes($bytes)
protected function skipbytes($bytes)
{
if ($this->comptype === Archive::COMPRESS_GZIP) {
@gzseek($this->fh, $bytes, SEEK_CUR);
@ -645,7 +645,7 @@ class Tar extends Archive
{
// for existing files, try to read the magic bytes
if(file_exists($file) && is_readable($file) && filesize($file) > 5) {
$fh = fopen($file, 'rb');
$fh = @fopen($file, 'rb');
if(!$fh) return false;
$magic = fread($fh, 5);
fclose($fh);

View File

@ -111,7 +111,7 @@ class Zip extends Archive
* @throws ArchiveIOException
* @return FileInfo[]
*/
function extract($outdir, $strip = '', $exclude = '', $include = '')
public function extract($outdir, $strip = '', $exclude = '', $include = '')
{
if ($this->closed || !$this->file) {
throw new ArchiveIOException('Can not read from a closed archive');
@ -163,7 +163,7 @@ class Zip extends Archive
}
// open file for writing
$fp = fopen($extractto, "wb");
$fp = @fopen($extractto, "wb");
if (!$fp) {
throw new ArchiveIOException('Could not open file for writing: '.$extractto);
}
@ -419,7 +419,7 @@ class Zip extends Archive
*/
public function save($file)
{
if (!file_put_contents($file, $this->getArchive())) {
if (!@file_put_contents($file, $this->getArchive())) {
throw new ArchiveIOException('Could not write to file: '.$file);
}
}
@ -629,12 +629,14 @@ class Zip extends Archive
* similar enough. CP437 seems not to be available in mbstring. Lastly falls back to keeping the
* string as is, which is still better than nothing.
*
* On some systems iconv is available, but the codepage is not. We also check for that.
*
* @param $string
* @return string
*/
protected function cpToUtf8($string)
{
if (function_exists('iconv')) {
if (function_exists('iconv') && @iconv_strlen('', 'CP437') !== false) {
return iconv('CP437', 'UTF-8', $string);
} elseif (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, 'UTF-8', 'CP850');