mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-08-26 08:34:21 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
42c0fc59df | ||
|
6688f474b5 | ||
|
810b7ca741 | ||
|
115dfd3b52 | ||
|
183274d6da |
@@ -1,9 +0,0 @@
|
|||||||
engines:
|
|
||||||
duplication:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
languages:
|
|
||||||
- php
|
|
||||||
exclude_paths:
|
|
||||||
- tests/
|
|
||||||
- vendor/
|
|
11
.travis.yml
11
.travis.yml
@@ -4,7 +4,6 @@ php:
|
|||||||
- '5.6'
|
- '5.6'
|
||||||
- '7.0'
|
- '7.0'
|
||||||
- '7.1'
|
- '7.1'
|
||||||
- hhvm
|
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
# cache vendor dirs
|
# cache vendor dirs
|
||||||
@@ -13,10 +12,6 @@ cache:
|
|||||||
- vendor
|
- vendor
|
||||||
- $HOME/.composer/cache
|
- $HOME/.composer/cache
|
||||||
|
|
||||||
addons:
|
|
||||||
code_climate:
|
|
||||||
repo_token: 486a09d58d663450146c53c81c6c64938bcf3bb0b7c8ddebdc125fe97c18213a
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- travis_retry composer self-update && composer --version
|
- travis_retry composer self-update && composer --version
|
||||||
- travis_retry composer install --prefer-dist --no-interaction
|
- travis_retry composer install --prefer-dist --no-interaction
|
||||||
@@ -26,8 +21,4 @@ before_script:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- composer validate --no-check-lock
|
- composer validate --no-check-lock
|
||||||
- vendor/bin/phpunit -v -c bootstrap.xml --coverage-clover build/logs/clover.xml
|
- vendor/bin/phpunit -v -c bootstrap.xml
|
||||||
|
|
||||||
after_success:
|
|
||||||
- vendor/bin/test-reporter
|
|
||||||
|
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
## 3.0.3 (2017-11-11)
|
||||||
|
Fix bug issue #8 - Error if the file is empty.
|
||||||
|
|
||||||
## 3.0.0 (2017-03-15)
|
## 3.0.0 (2017-03-15)
|
||||||
Merge `ZipOutputFile` with ZipFile and optimize the zip archive update.
|
Merge `ZipOutputFile` with ZipFile and optimize the zip archive update.
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
[](https://packagist.org/packages/nelexa/zip)
|
[](https://packagist.org/packages/nelexa/zip)
|
||||||
[](https://packagist.org/packages/nelexa/zip)
|
[](https://packagist.org/packages/nelexa/zip)
|
||||||
[](https://php.net/)
|
[](https://php.net/)
|
||||||
[](https://codeclimate.com/github/Ne-Lexa/php-zip/coverage)
|
|
||||||
[](https://packagist.org/packages/nelexa/zip)
|
[](https://packagist.org/packages/nelexa/zip)
|
||||||
|
|
||||||
Table of contents
|
Table of contents
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"require": {
|
"require": {
|
||||||
"php-64bit": "^5.5 || ^7.0"
|
"php": "^5.5 || ^7.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace PhpZip\Model\Entry;
|
namespace PhpZip\Model\Entry;
|
||||||
|
|
||||||
use PhpZip\Exception\InvalidArgumentException;
|
use PhpZip\Exception\InvalidArgumentException;
|
||||||
@@ -257,6 +258,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
public function setCompressedSize($compressedSize)
|
public function setCompressedSize($compressedSize)
|
||||||
{
|
{
|
||||||
if (self::UNKNOWN != $compressedSize) {
|
if (self::UNKNOWN != $compressedSize) {
|
||||||
|
$compressedSize = sprintf('%u', $compressedSize);
|
||||||
if (0 > $compressedSize || $compressedSize > 0x7fffffffffffffff) {
|
if (0 > $compressedSize || $compressedSize > 0x7fffffffffffffff) {
|
||||||
throw new ZipException("Compressed size out of range - " . $this->name);
|
throw new ZipException("Compressed size out of range - " . $this->name);
|
||||||
}
|
}
|
||||||
@@ -285,6 +287,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
public function setSize($size)
|
public function setSize($size)
|
||||||
{
|
{
|
||||||
if (self::UNKNOWN != $size) {
|
if (self::UNKNOWN != $size) {
|
||||||
|
$size = sprintf('%u', $size);
|
||||||
if (0 > $size || $size > 0x7fffffffffffffff) {
|
if (0 > $size || $size > 0x7fffffffffffffff) {
|
||||||
throw new ZipException("Uncompressed Size out of range - " . $this->name);
|
throw new ZipException("Uncompressed Size out of range - " . $this->name);
|
||||||
}
|
}
|
||||||
@@ -310,6 +313,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
*/
|
*/
|
||||||
public function setOffset($offset)
|
public function setOffset($offset)
|
||||||
{
|
{
|
||||||
|
$offset = sprintf('%u', $offset);
|
||||||
if (0 > $offset || $offset > 0x7fffffffffffffff) {
|
if (0 > $offset || $offset > 0x7fffffffffffffff) {
|
||||||
throw new ZipException("Offset out of range - " . $this->name);
|
throw new ZipException("Offset out of range - " . $this->name);
|
||||||
}
|
}
|
||||||
@@ -523,6 +527,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
*/
|
*/
|
||||||
public function setDosTime($dosTime)
|
public function setDosTime($dosTime)
|
||||||
{
|
{
|
||||||
|
$dosTime = sprintf('%u', $dosTime);
|
||||||
if (0x00000000 > $dosTime || $dosTime > 0xffffffff) {
|
if (0x00000000 > $dosTime || $dosTime > 0xffffffff) {
|
||||||
throw new ZipException('DosTime out of range');
|
throw new ZipException('DosTime out of range');
|
||||||
}
|
}
|
||||||
@@ -554,6 +559,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
{
|
{
|
||||||
$known = self::UNKNOWN != $externalAttributes;
|
$known = self::UNKNOWN != $externalAttributes;
|
||||||
if ($known) {
|
if ($known) {
|
||||||
|
$externalAttributes = sprintf('%u', $externalAttributes);
|
||||||
if (0x00000000 > $externalAttributes || $externalAttributes > 0xffffffff) {
|
if (0x00000000 > $externalAttributes || $externalAttributes > 0xffffffff) {
|
||||||
throw new ZipException("external file attributes out of range - " . $this->name);
|
throw new ZipException("external file attributes out of range - " . $this->name);
|
||||||
}
|
}
|
||||||
@@ -847,6 +853,7 @@ abstract class ZipAbstractEntry implements ZipEntry
|
|||||||
*/
|
*/
|
||||||
public function setCrc($crc)
|
public function setCrc($crc)
|
||||||
{
|
{
|
||||||
|
$crc = sprintf('%u', $crc);
|
||||||
if (0x00000000 > $crc || $crc > 0xffffffff) {
|
if (0x00000000 > $crc || $crc > 0xffffffff) {
|
||||||
throw new ZipException("CRC-32 out of range - " . $this->name);
|
throw new ZipException("CRC-32 out of range - " . $this->name);
|
||||||
}
|
}
|
||||||
|
@@ -258,7 +258,7 @@ abstract class ZipNewEntry extends ZipAbstractEntry
|
|||||||
} else {
|
} else {
|
||||||
fwrite($outputStream, pack('VV', $this->getCompressedSize(), $this->getSize()));
|
fwrite($outputStream, pack('VV', $this->getCompressedSize(), $this->getSize()));
|
||||||
}
|
}
|
||||||
} elseif ($this->getCompressedSize() !== $compressedSize) {
|
} elseif ($this->getCompressedSize() != $compressedSize) {
|
||||||
throw new ZipException($this->getName()
|
throw new ZipException($this->getName()
|
||||||
. " (expected compressed entry size of "
|
. " (expected compressed entry size of "
|
||||||
. $this->getCompressedSize() . " bytes, but is actually " . $compressedSize . " bytes)");
|
. $this->getCompressedSize() . " bytes, but is actually " . $compressedSize . " bytes)");
|
||||||
|
@@ -151,7 +151,10 @@ class ZipReadEntry extends ZipAbstractEntry
|
|||||||
fseek($this->inputStream, $pos);
|
fseek($this->inputStream, $pos);
|
||||||
|
|
||||||
// Get raw entry content
|
// Get raw entry content
|
||||||
$content = fread($this->inputStream, $this->getCompressedSize());
|
$content = '';
|
||||||
|
if ($this->getCompressedSize() > 0) {
|
||||||
|
$content = fread($this->inputStream, $this->getCompressedSize());
|
||||||
|
}
|
||||||
|
|
||||||
// Strong Encryption Specification - WinZip AES
|
// Strong Encryption Specification - WinZip AES
|
||||||
if ($this->isEncrypted()) {
|
if ($this->isEncrypted()) {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace PhpZip;
|
namespace PhpZip;
|
||||||
|
|
||||||
use PhpZip\Exception\ZipAuthenticationException;
|
use PhpZip\Exception\ZipAuthenticationException;
|
||||||
@@ -1811,6 +1812,19 @@ class ZipFileTest extends ZipTestCase
|
|||||||
self::assertTrue($result);
|
self::assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyContents()
|
||||||
|
{
|
||||||
|
$zipFile = new ZipFile();
|
||||||
|
$contents = '';
|
||||||
|
$zipFile->addFromString('file', $contents);
|
||||||
|
$zipFile->saveAsFile($this->outputFilename);
|
||||||
|
$zipFile->close();
|
||||||
|
|
||||||
|
$zipFile->openFile($this->outputFilename);
|
||||||
|
self::assertEquals($zipFile['file'], $contents);
|
||||||
|
$zipFile->close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test support ZIP64 ext (slow test - normal).
|
* Test support ZIP64 ext (slow test - normal).
|
||||||
* Create > 65535 files in archive and open and extract to /dev/null.
|
* Create > 65535 files in archive and open and extract to /dev/null.
|
||||||
|
Reference in New Issue
Block a user