diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/phar/tests/zip/files | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/phar/tests/zip/files')
68 files changed, 689 insertions, 0 deletions
diff --git a/ext/phar/tests/zip/files/badalias1.phar.zip b/ext/phar/tests/zip/files/badalias1.phar.zip Binary files differnew file mode 100644 index 0000000..0e3adfc --- /dev/null +++ b/ext/phar/tests/zip/files/badalias1.phar.zip diff --git a/ext/phar/tests/zip/files/badalias2.phar.zip b/ext/phar/tests/zip/files/badalias2.phar.zip Binary files differnew file mode 100644 index 0000000..7b5baaa --- /dev/null +++ b/ext/phar/tests/zip/files/badalias2.phar.zip diff --git a/ext/phar/tests/zip/files/badalias3.phar.zip b/ext/phar/tests/zip/files/badalias3.phar.zip Binary files differnew file mode 100644 index 0000000..7b5baaa --- /dev/null +++ b/ext/phar/tests/zip/files/badalias3.phar.zip diff --git a/ext/phar/tests/zip/files/badalias4.phar.zip b/ext/phar/tests/zip/files/badalias4.phar.zip Binary files differnew file mode 100644 index 0000000..49b7be0 --- /dev/null +++ b/ext/phar/tests/zip/files/badalias4.phar.zip diff --git a/ext/phar/tests/zip/files/badalias5.phar.zip b/ext/phar/tests/zip/files/badalias5.phar.zip Binary files differnew file mode 100644 index 0000000..9f2b0e8 --- /dev/null +++ b/ext/phar/tests/zip/files/badalias5.phar.zip diff --git a/ext/phar/tests/zip/files/bz2_alias.phar.zip b/ext/phar/tests/zip/files/bz2_alias.phar.zip Binary files differnew file mode 100644 index 0000000..8d3082a --- /dev/null +++ b/ext/phar/tests/zip/files/bz2_alias.phar.zip diff --git a/ext/phar/tests/zip/files/bzip2.zip b/ext/phar/tests/zip/files/bzip2.zip Binary files differnew file mode 100644 index 0000000..2f27f02 --- /dev/null +++ b/ext/phar/tests/zip/files/bzip2.zip diff --git a/ext/phar/tests/zip/files/cdir_offset.zip b/ext/phar/tests/zip/files/cdir_offset.zip Binary files differnew file mode 100644 index 0000000..9172554 --- /dev/null +++ b/ext/phar/tests/zip/files/cdir_offset.zip diff --git a/ext/phar/tests/zip/files/compress_unsup1.zip b/ext/phar/tests/zip/files/compress_unsup1.zip Binary files differnew file mode 100644 index 0000000..bd1f72b --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup1.zip diff --git a/ext/phar/tests/zip/files/compress_unsup10.zip b/ext/phar/tests/zip/files/compress_unsup10.zip Binary files differnew file mode 100644 index 0000000..2a7f221 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup10.zip diff --git a/ext/phar/tests/zip/files/compress_unsup14.zip b/ext/phar/tests/zip/files/compress_unsup14.zip Binary files differnew file mode 100644 index 0000000..d494143 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup14.zip diff --git a/ext/phar/tests/zip/files/compress_unsup18.zip b/ext/phar/tests/zip/files/compress_unsup18.zip Binary files differnew file mode 100644 index 0000000..7ef2217 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup18.zip diff --git a/ext/phar/tests/zip/files/compress_unsup19.zip b/ext/phar/tests/zip/files/compress_unsup19.zip Binary files differnew file mode 100644 index 0000000..8086d45 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup19.zip diff --git a/ext/phar/tests/zip/files/compress_unsup2.zip b/ext/phar/tests/zip/files/compress_unsup2.zip Binary files differnew file mode 100644 index 0000000..d827d2d --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup2.zip diff --git a/ext/phar/tests/zip/files/compress_unsup3.zip b/ext/phar/tests/zip/files/compress_unsup3.zip Binary files differnew file mode 100644 index 0000000..d4acc60 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup3.zip diff --git a/ext/phar/tests/zip/files/compress_unsup4.zip b/ext/phar/tests/zip/files/compress_unsup4.zip Binary files differnew file mode 100644 index 0000000..76a4dc1 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup4.zip diff --git a/ext/phar/tests/zip/files/compress_unsup5.zip b/ext/phar/tests/zip/files/compress_unsup5.zip Binary files differnew file mode 100644 index 0000000..d42155d --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup5.zip diff --git a/ext/phar/tests/zip/files/compress_unsup6.zip b/ext/phar/tests/zip/files/compress_unsup6.zip Binary files differnew file mode 100644 index 0000000..5084640 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup6.zip diff --git a/ext/phar/tests/zip/files/compress_unsup7.zip b/ext/phar/tests/zip/files/compress_unsup7.zip Binary files differnew file mode 100644 index 0000000..65c2e23 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup7.zip diff --git a/ext/phar/tests/zip/files/compress_unsup9.zip b/ext/phar/tests/zip/files/compress_unsup9.zip Binary files differnew file mode 100644 index 0000000..df0c767 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup9.zip diff --git a/ext/phar/tests/zip/files/compress_unsup97.zip b/ext/phar/tests/zip/files/compress_unsup97.zip Binary files differnew file mode 100644 index 0000000..907f365 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup97.zip diff --git a/ext/phar/tests/zip/files/compress_unsup98.zip b/ext/phar/tests/zip/files/compress_unsup98.zip Binary files differnew file mode 100644 index 0000000..54f19fb --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsup98.zip diff --git a/ext/phar/tests/zip/files/compress_unsupunknown.zip b/ext/phar/tests/zip/files/compress_unsupunknown.zip Binary files differnew file mode 100644 index 0000000..1706954 --- /dev/null +++ b/ext/phar/tests/zip/files/compress_unsupunknown.zip diff --git a/ext/phar/tests/zip/files/corrupt2.php.inc b/ext/phar/tests/zip/files/corrupt2.php.inc new file mode 100644 index 0000000..3edf620 --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt2.php.inc @@ -0,0 +1,60 @@ +<?php +include dirname(__FILE__) . '/corrupt_zipmaker.php.inc'; +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii'); +$a->addFile('hi2', null, 'hii2', null, null, 'encrypt', 'encrypt'); +$a->writeZip(dirname(__FILE__) . '/encrypted.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii'); +$a->addFile('', null, 'stdin'); +$a->writeZip(dirname(__FILE__) . '/stdin.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hii', null, 'hii', null, null, 'filename_len', 'filename_len'); +$a->addFile('hi', null, 'hii'); +$a->writeZip(dirname(__FILE__) . '/truncfilename.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress'); +$a->writeZip(dirname(__FILE__) . '/compress_unsup1.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 2); +$a->writeZip(dirname(__FILE__) . '/compress_unsup2.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 3); +$a->writeZip(dirname(__FILE__) . '/compress_unsup3.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 4); +$a->writeZip(dirname(__FILE__) . '/compress_unsup4.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 5); +$a->writeZip(dirname(__FILE__) . '/compress_unsup5.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 6); +$a->writeZip(dirname(__FILE__) . '/compress_unsup6.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 7); +$a->writeZip(dirname(__FILE__) . '/compress_unsup7.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 9); +$a->writeZip(dirname(__FILE__) . '/compress_unsup9.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 10); +$a->writeZip(dirname(__FILE__) . '/compress_unsup10.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 14); +$a->writeZip(dirname(__FILE__) . '/compress_unsup14.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 18); +$a->writeZip(dirname(__FILE__) . '/compress_unsup18.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 19); +$a->writeZip(dirname(__FILE__) . '/compress_unsup19.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 97); +$a->writeZip(dirname(__FILE__) . '/compress_unsup97.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 98); +$a->writeZip(dirname(__FILE__) . '/compress_unsup98.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11); +$a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip'); +?> diff --git a/ext/phar/tests/zip/files/corrupt3.php.inc b/ext/phar/tests/zip/files/corrupt3.php.inc new file mode 100644 index 0000000..05ba70b --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt3.php.inc @@ -0,0 +1,9 @@ +<?php +include dirname(__FILE__) . '/corrupt_zipmaker.php.inc'; +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii', null, null, null, 'extralen1'); +$a->writeZip(dirname(__FILE__) . '/extralen_toolong.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii'); +$a->writeZip(dirname(__FILE__) . '/disknumber.zip', 'disknumber'); +?> diff --git a/ext/phar/tests/zip/files/corrupt_count1.php.inc b/ext/phar/tests/zip/files/corrupt_count1.php.inc new file mode 100644 index 0000000..314fdef --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt_count1.php.inc @@ -0,0 +1,11 @@ +<?php +include dirname(__FILE__) . '/corrupt_zipmaker.php.inc'; +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii'); +$a->addFile('hi2', null, 'hii2'); +$a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1'); +$a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2'); +$a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none'); +$a->writeZip(dirname(__FILE__) . '/filecomment.zip', 'comment'); +$a->writeZip(dirname(__FILE__) . '/cdir_offset.zip', 'cdir_offset'); +?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc new file mode 100644 index 0000000..9fbfe34 --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc @@ -0,0 +1,332 @@ +<?php +// this corrupt zip maker uses portions of Vincent Lascaux's File_Archive to create +// specifically corrupted zip archives for unit-testing zip support in the phar extension +// and was modified by Greg Beaver +/** + * ZIP archive writer + * + * PHP versions 4 and 5 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA + * + * @category File Formats + * @package File_Archive + * @author Vincent Lascaux <vincentlascaux@php.net> + * @copyright 1997-2005 The PHP Group + * @license http://www.gnu.org/copyleft/lesser.html LGPL + * @version CVS: $Id$ + * @link http://pear.php.net/package/File_Archive + */ + +/** + * ZIP archive writer + */ +class corrupt_zipmaker +{ + /** + * @var int Current position in the writer + * @access private + */ + var $offset = 0; + + /** + * @var string Optionnal comment to add to the zip + * @access private + */ + var $comment = ""; + + /** + * @var string Data written at the end of the ZIP file + * @access private + */ + var $central = ""; + + /** + * @var string Data written at the start of the ZIP file + * @access private + */ + var $start = ""; + + /** + * Set a comment on the ZIP file + */ + function setComment($comment) { $this->comment = $comment; } + + /** + * @param int $time Unix timestamp of the date to convert + * @return the date formated as a ZIP date + */ + function getMTime($time) + { + $mtime = ($time !== null ? getdate($time) : getdate()); + $mtime = preg_replace( + "/(..){1}(..){1}(..){1}(..){1}/", + "\\x\\4\\x\\3\\x\\2\\x\\1", + dechex(($mtime['year']-1980<<25)| + ($mtime['mon' ]<<21)| + ($mtime['mday' ]<<16)| + ($mtime['hours' ]<<11)| + ($mtime['minutes']<<5)| + ($mtime['seconds']>>1))); + eval('$mtime = "'.$mtime.'";'); + return $mtime; + } + + private function getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $corrupt, $fakecomp) + { + switch ($corrupt) { + case null : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'compress' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $fakecomp) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'encrypt' : + $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'crc32' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'complength' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength + 1, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'uncomplength' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00) . + $filename . + $data; + break; + case 'filename_len' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00) . + $filename . + $data; + break; + case 'extra_len' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 1) . + $filename . + $data; + break; + case 'filename' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + substr($filename, 1) . + $data; + break; + case 'data' : + $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + substr($data, 1); + break; + } + return $file; + } + + private function getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $corrupt, &$offset, $fakecomp) + { + settype($comment, 'string'); + switch ($corrupt) { + case null : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'encrypt' : + $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'compress' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $fakecomp) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'crc32' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32 + 1, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'complength' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength - 1, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'uncomplength' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength - 1, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'filename_len' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename) - 1, 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'offset' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset - 1). + $filename . $comment; + $offset = strlen($central) - 1; + break; + case 'comment' : + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment) + 1,0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; + case 'extralen1' : + $extra = 'nu' . 0xffff; // way huge size + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $extra . $comment; + $offset = strlen($central); + break; + } + return $central; + } + + function addFile($filename, $mtime, $data, $comment = null, $compress = null, $filecorrupt = null, $centralcorrupt = null, $fakecomp = 1) + { + $mtime = $this->getMTime($mtime ? $mtime : null); + + $uncomplength = strlen($data); + $crc32 = crc32($data) & 0xFFFFFFFF; + $compmethod = 0; + switch ($compress) { + case 'gz' : + $data = gzcompress($data); + $compmethod = 8; + break; + case 'bz2' : + $data = bzcompress($data); + $compmethod = 12; + break; + } + $complength = strlen($data); + + $this->start .= ($file = $this->getFileEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $data, $filecorrupt, $fakecomp)); + + $offset = 0; + $this->central .= $this->getCentralEntry($compmethod, $mtime, $crc32, $complength, $uncomplength, $filename, $comment, $centralcorrupt, $offset, $fakecomp); + + $this->offset += $offset; + $this->count++; + } + + function writeZip($zipfile, $corrupt = null) + { + $write = $this->start . $this->central; + switch ($corrupt) { + case null : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'disknumber' : + $write .= "PK\x05\x06\x01\x00\x01\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'count1' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count + 1, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'count2' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count + 1, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'cdir_offset' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start) - 3, + strlen($this->comment)) . $this->comment; + break; + case 'cdir_len' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset - 5, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; + case 'comment' : + $write .= "PK\x05\x06\x00\x00\x00\x00" . + pack("vvVVv", $this->count, $this->count, + strlen($this->start), $this->offset + 1, + strlen($this->comment) + 1) . $this->comment; + break; + case 'none' : + } + file_put_contents($zipfile, $write); + } +} +?>
\ No newline at end of file diff --git a/ext/phar/tests/zip/files/count1.zip b/ext/phar/tests/zip/files/count1.zip Binary files differnew file mode 100644 index 0000000..73b5561 --- /dev/null +++ b/ext/phar/tests/zip/files/count1.zip diff --git a/ext/phar/tests/zip/files/count2.zip b/ext/phar/tests/zip/files/count2.zip Binary files differnew file mode 100644 index 0000000..6aa2619 --- /dev/null +++ b/ext/phar/tests/zip/files/count2.zip diff --git a/ext/phar/tests/zip/files/disknumber.zip b/ext/phar/tests/zip/files/disknumber.zip Binary files differnew file mode 100644 index 0000000..f20db05 --- /dev/null +++ b/ext/phar/tests/zip/files/disknumber.zip diff --git a/ext/phar/tests/zip/files/encrypted.zip b/ext/phar/tests/zip/files/encrypted.zip Binary files differnew file mode 100644 index 0000000..dee73ca --- /dev/null +++ b/ext/phar/tests/zip/files/encrypted.zip diff --git a/ext/phar/tests/zip/files/extralen_toolong.zip b/ext/phar/tests/zip/files/extralen_toolong.zip Binary files differnew file mode 100644 index 0000000..a03a403 --- /dev/null +++ b/ext/phar/tests/zip/files/extralen_toolong.zip diff --git a/ext/phar/tests/zip/files/filecomment.zip b/ext/phar/tests/zip/files/filecomment.zip Binary files differnew file mode 100644 index 0000000..414b121 --- /dev/null +++ b/ext/phar/tests/zip/files/filecomment.zip diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.inc b/ext/phar/tests/zip/files/frontcontroller.phar.inc new file mode 100644 index 0000000..241dceb --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller.phar.inc @@ -0,0 +1,13 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a['index.php'] = 'here is my index'; +$a->setStub('<?php +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.zip b/ext/phar/tests/zip/files/frontcontroller.phar.zip Binary files differnew file mode 100644 index 0000000..28992ff --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.inc b/ext/phar/tests/zip/files/frontcontroller10.phar.inc new file mode 100644 index 0000000..c973cc1 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller10.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller10.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER["SCRIPT_NAME"]); +var_dump($_SERVER["SCRIPT_FILENAME"]); +var_dump($_SERVER["REQUEST_URI"]); +var_dump($_SERVER["PHAR_PHP_SELF"]); +var_dump($_SERVER["PHAR_SCRIPT_NAME"]); +var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER["PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.zip b/ext/phar/tests/zip/files/frontcontroller10.phar.zip Binary files differnew file mode 100644 index 0000000..d206c89 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller10.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.inc b/ext/phar/tests/zip/files/frontcontroller11.phar.inc new file mode 100644 index 0000000..c24a6f1 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller11.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller11.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER["SCRIPT_NAME"]); +var_dump($_SERVER["SCRIPT_FILENAME"]); +var_dump($_SERVER["REQUEST_URI"]); +var_dump($_SERVER["PHAR_PHP_SELF"]); +var_dump($_SERVER["PHAR_SCRIPT_NAME"]); +var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER["PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.zip b/ext/phar/tests/zip/files/frontcontroller11.phar.zip Binary files differnew file mode 100644 index 0000000..9942183 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller11.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc new file mode 100644 index 0000000..c5f38ff --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller12.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller12.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER[b"SCRIPT_NAME"]); +var_dump($_SERVER[b"SCRIPT_FILENAME"]); +var_dump($_SERVER[b"REQUEST_URI"]); +var_dump($_SERVER[b"PHAR_PHP_SELF"]); +var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]); +var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER[b"PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.zip b/ext/phar/tests/zip/files/frontcontroller12.phar.zip Binary files differnew file mode 100644 index 0000000..ed9be3d --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.inc b/ext/phar/tests/zip/files/frontcontroller2.phar.inc new file mode 100644 index 0000000..6cfa052 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller2.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller2.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "a.php"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.zip b/ext/phar/tests/zip/files/frontcontroller2.phar.zip Binary files differnew file mode 100644 index 0000000..3d7c0bb --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller2.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc new file mode 100644 index 0000000..ccd55b7 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller3.phar.inc @@ -0,0 +1,18 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller3.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +function s($a) +{ + static $b = array(b"/hi" => b"a.phps"); + if (isset($b[$a])) return $b[$a]; + return $a; +} +Phar::webPhar("whatever", "/index.php", null, array(), "s"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.zip b/ext/phar/tests/zip/files/frontcontroller3.phar.zip Binary files differnew file mode 100644 index 0000000..6f35a80 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc new file mode 100644 index 0000000..9f664cf --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller4.phar.inc @@ -0,0 +1,18 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller4.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +function s($a) +{ + static $b = array(b"/hi" => false); + if (isset($b[$a])) return $b[$a]; + return $a; +} +Phar::webPhar("whatever", "index.php", null, array(), "s"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.zip b/ext/phar/tests/zip/files/frontcontroller4.phar.zip Binary files differnew file mode 100644 index 0000000..fb27ccb --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.inc b/ext/phar/tests/zip/files/frontcontroller5.phar.inc new file mode 100644 index 0000000..931fa97 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller5.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller5.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array(0 => "oops")); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.zip b/ext/phar/tests/zip/files/frontcontroller5.phar.zip Binary files differnew file mode 100644 index 0000000..7fa7ab6 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller5.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.inc b/ext/phar/tests/zip/files/frontcontroller6.phar.inc new file mode 100644 index 0000000..da178fe --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller6.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller6.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("php" => 100)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.zip b/ext/phar/tests/zip/files/frontcontroller6.phar.zip Binary files differnew file mode 100644 index 0000000..eac313c --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller6.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.inc b/ext/phar/tests/zip/files/frontcontroller7.phar.inc new file mode 100644 index 0000000..a186491 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller7.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller7.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("php" => null)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.zip b/ext/phar/tests/zip/files/frontcontroller7.phar.zip Binary files differnew file mode 100644 index 0000000..be72052 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller7.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller8.phar.inc b/ext/phar/tests/zip/files/frontcontroller8.phar.inc new file mode 100644 index 0000000..e04ac41 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller8.phar.inc @@ -0,0 +1,13 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller8.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.zip'); +$a['a.phps'] = 'hio1'; +$a['a.jpg'] = 'hio2'; +$a['a.php'] = '<?php function hio(){}'; +$a['fronk.gronk'] = 'hio3'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller8.phar.zip b/ext/phar/tests/zip/files/frontcontroller8.phar.zip Binary files differnew file mode 100644 index 0000000..d065cd5 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller8.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller9.phar.inc b/ext/phar/tests/zip/files/frontcontroller9.phar.inc new file mode 100644 index 0000000..5044045 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller9.phar.inc @@ -0,0 +1,14 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller9.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.zip'); +$a['a.phps'] = 'hio1'; +$a['a.jpg'] = 'hio2'; +$a['a.php'] = '<?php function hio(){}'; +$a['fronk.gronk'] = 'hio3'; +$a->setStub('<?php +Phar::mungServer(array()); +Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller9.phar.zip b/ext/phar/tests/zip/files/frontcontroller9.phar.zip Binary files differnew file mode 100644 index 0000000..82c4eb7 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller9.phar.zip diff --git a/ext/phar/tests/zip/files/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc new file mode 100644 index 0000000..cec8ef7 --- /dev/null +++ b/ext/phar/tests/zip/files/make_invalid_tar.php.inc @@ -0,0 +1,12 @@ +<?php +include dirname(__FILE__) . '/tarmaker.php.inc'; +class corrupter extends tarmaker { +function close() +{ + parent::close(); + $fp = fopen($this->path, 'r+b'); + fseek($fp, 20); + fwrite($fp, 'oopsie'); + fclose($fp); +} +}
\ No newline at end of file diff --git a/ext/phar/tests/zip/files/metadata.phar.inc b/ext/phar/tests/zip/files/metadata.phar.inc new file mode 100644 index 0000000..932fc96 --- /dev/null +++ b/ext/phar/tests/zip/files/metadata.phar.inc @@ -0,0 +1,11 @@ +<?php +@unlink(dirname(__FILE__) . '/metadata.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/metadata.phar.zip'); +$a['a'] = 'a'; +$a['b'] = 'b'; +$a['b']->setMetadata('hi there'); +$a['c'] = 'c'; +$a['c']->setMetadata(array('hi', 'there')); +$a['d'] = 'd'; +$a['d']->setMetadata(array('hi'=>'there','foo'=>'bar')); +?> diff --git a/ext/phar/tests/zip/files/metadata.phar.zip b/ext/phar/tests/zip/files/metadata.phar.zip Binary files differnew file mode 100644 index 0000000..3c5cf00 --- /dev/null +++ b/ext/phar/tests/zip/files/metadata.phar.zip diff --git a/ext/phar/tests/zip/files/nozipend.zip b/ext/phar/tests/zip/files/nozipend.zip Binary files differnew file mode 100644 index 0000000..f976072 --- /dev/null +++ b/ext/phar/tests/zip/files/nozipend.zip diff --git a/ext/phar/tests/zip/files/odt.odt b/ext/phar/tests/zip/files/odt.odt Binary files differnew file mode 100644 index 0000000..527e09f --- /dev/null +++ b/ext/phar/tests/zip/files/odt.odt diff --git a/ext/phar/tests/zip/files/stdin.zip b/ext/phar/tests/zip/files/stdin.zip Binary files differnew file mode 100644 index 0000000..4376eb6 --- /dev/null +++ b/ext/phar/tests/zip/files/stdin.zip diff --git a/ext/phar/tests/zip/files/test.odt b/ext/phar/tests/zip/files/test.odt Binary files differnew file mode 100644 index 0000000..c5cefe5 --- /dev/null +++ b/ext/phar/tests/zip/files/test.odt diff --git a/ext/phar/tests/zip/files/truncfilename.zip b/ext/phar/tests/zip/files/truncfilename.zip Binary files differnew file mode 100644 index 0000000..d8a526a --- /dev/null +++ b/ext/phar/tests/zip/files/truncfilename.zip diff --git a/ext/phar/tests/zip/files/zip.zip b/ext/phar/tests/zip/files/zip.zip Binary files differnew file mode 100644 index 0000000..5ee9cae --- /dev/null +++ b/ext/phar/tests/zip/files/zip.zip diff --git a/ext/phar/tests/zip/files/zipmaker.php.inc b/ext/phar/tests/zip/files/zipmaker.php.inc new file mode 100644 index 0000000..aceab0d --- /dev/null +++ b/ext/phar/tests/zip/files/zipmaker.php.inc @@ -0,0 +1,70 @@ +<?php +// stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests +class zipmaker +{ + /** + * Path to archive file + * + * @var string + */ + protected $archive; + /** + * @var ZIPArchive + */ + protected $zip; + protected $path; + function __construct($path) + { + if (!class_exists('ZIPArchive')) { + throw new Exception( + 'Zip extension is not available'); + } + $this->path = $path; + } + + /** + * save a file inside this package + * @param string relative path within the package + * @param string|resource file contents or open file handle + */ + function addFile($path, $fileOrStream) + { + if (is_resource($fileOrStream)) { + $this->zip->addFromString($path, stream_get_contents($fileOrStream)); + } else { + $this->zip->addFromString($path, $fileOrStream); + } + } + + /** + * Initialize the package creator + */ + function init() + { + $this->zip = new ZipArchive; + if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) { + throw new Exception( + 'Cannot open ZIP archive ' . $this->path + ); + } + } + + /** + * Create an internal directory, creating parent directories as needed + * + * This is a no-op for the tar creator + * @param string $dir + */ + function mkdir($dir) + { + $this->zip->addEmptyDir($dir); + } + + /** + * Finish saving the package + */ + function close() + { + $this->zip->close(); + } +}
\ No newline at end of file diff --git a/ext/phar/tests/zip/files/zlib_alias.phar.zip b/ext/phar/tests/zip/files/zlib_alias.phar.zip Binary files differnew file mode 100644 index 0000000..d6f98e8 --- /dev/null +++ b/ext/phar/tests/zip/files/zlib_alias.phar.zip |