summaryrefslogtreecommitdiff
path: root/ext/phar/tests/tar/files
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/phar/tests/tar/files
downloadphp2-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/tar/files')
-rw-r--r--ext/phar/tests/tar/files/Net_URL-1.0.15.tgzbin0 -> 6303 bytes
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgzbin0 -> 1284 bytes
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey9
-rw-r--r--ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgzbin0 -> 30191 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias1.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias2.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias3.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias4.phar.tarbin0 -> 3072 bytes
-rw-r--r--ext/phar/tests/tar/files/badalias5.phar.tarbin0 -> 3584 bytes
-rw-r--r--ext/phar/tests/tar/files/biglink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/corrupt_tarmaker.php.inc177
-rw-r--r--ext/phar/tests/tar/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/tar/files/frontcontroller.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller10.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller11.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.tarbin0 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller2.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller5.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller6.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/tar/files/frontcontroller7.phar.tarbin0 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller8.phar.inc13
-rw-r--r--ext/phar/tests/tar/files/frontcontroller8.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/tar/files/frontcontroller9.phar.tarbin0 -> 7168 bytes
-rw-r--r--ext/phar/tests/tar/files/links.phar.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/links.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/make.dangerous.tar.php.inc170
-rw-r--r--ext/phar/tests/tar/files/make_invalid_tar.php.inc9
-rw-r--r--ext/phar/tests/tar/files/subdirlink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/tarmaker.php.inc169
-rw-r--r--ext/phar/tests/tar/files/tinylink.tarbin0 -> 10240 bytes
-rw-r--r--ext/phar/tests/tar/files/trunc.tarbin0 -> 800 bytes
43 files changed, 718 insertions, 0 deletions
diff --git a/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz b/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz
new file mode 100644
index 0000000..976603d
--- /dev/null
+++ b/ext/phar/tests/tar/files/Net_URL-1.0.15.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz b/ext/phar/tests/tar/files/P1-1.0.0.tgz
new file mode 100644
index 0000000..1d9cae4
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
new file mode 100644
index 0000000..eb59bdd
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4drcwddPs6LmIbdT1ifT
+Ev8HXh1Fk1yNusCDoCX6mYkgqvCmx02F/9k5q7n6CPblTcF5mdDI8kcRrUHmyXtD
+9X0d7RN7BakZMPH5KPaNkXiXsI9YGSb39AnZgYw01n6u0W6Ohha+KwOsrxkKCF4u
+LjPLQAlM+3uD8y9Tz2fF+pAE901kHrd3ue7a5i5EtW0bzl5QfxnwFZXAO0StQ9dF
+slzibRH+1pFjMRxDnlgYmLQF6jMWm9Ty6x9UH9HZ3E3F9QZEQVXWT9y/pe30HcAX
+YxAGZjPIx19UNPF5C+Nps6MjxNRht0pGXTL9sptYoiNjRiXAS0y4FM+8K6xvBIOF
+ZQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
new file mode 100644
index 0000000..fa14f0c
--- /dev/null
+++ b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias1.phar.tar b/ext/phar/tests/tar/files/badalias1.phar.tar
new file mode 100644
index 0000000..6cd4716
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias1.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias2.phar.tar b/ext/phar/tests/tar/files/badalias2.phar.tar
new file mode 100644
index 0000000..5face85
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias2.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias3.phar.tar b/ext/phar/tests/tar/files/badalias3.phar.tar
new file mode 100644
index 0000000..ab36e1f
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias3.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias4.phar.tar b/ext/phar/tests/tar/files/badalias4.phar.tar
new file mode 100644
index 0000000..c54e31d
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias4.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/badalias5.phar.tar b/ext/phar/tests/tar/files/badalias5.phar.tar
new file mode 100644
index 0000000..dd52b6a
--- /dev/null
+++ b/ext/phar/tests/tar/files/badalias5.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/biglink.tar b/ext/phar/tests/tar/files/biglink.tar
new file mode 100644
index 0000000..43bbf58
--- /dev/null
+++ b/ext/phar/tests/tar/files/biglink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc
new file mode 100644
index 0000000..b0eba6c
--- /dev/null
+++ b/ext/phar/tests/tar/files/corrupt_tarmaker.php.inc
@@ -0,0 +1,177 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+class corrupt_tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null, $corrupt = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0xA000 && $corrupt === 'symlink') {
+ $type = 2; // Symbolic Link
+ $link = $fileOrStream;
+ $stat['size'] = 0;
+ $fileOrStream = '';
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = $fileOrStream;
+ $stat['size'] = 0;
+ $fileOrStream = '';
+ } else if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ decoct($stat['mode']),
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '');
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ if ($corrupt === 'checksum') $checksum++;
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, $block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, $fileOrStream);
+ if (strlen($fileOrStream) && !isset($link) && strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/frontcontroller.phar.inc b/ext/phar/tests/tar/files/frontcontroller.phar.inc
new file mode 100644
index 0000000..6f426e8
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.tar');
+$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/tar/files/frontcontroller.phar.tar b/ext/phar/tests/tar/files/frontcontroller.phar.tar
new file mode 100644
index 0000000..02d8766
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller10.phar.inc b/ext/phar/tests/tar/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000..5b132fa
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.tar');
+$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/tar/files/frontcontroller10.phar.tar b/ext/phar/tests/tar/files/frontcontroller10.phar.tar
new file mode 100644
index 0000000..574d7cd
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller10.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller11.phar.inc b/ext/phar/tests/tar/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000..2fa15f0
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.tar');
+$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/tar/files/frontcontroller11.phar.tar b/ext/phar/tests/tar/files/frontcontroller11.phar.tar
new file mode 100644
index 0000000..08cbdc1
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller11.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.inc b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000..0a9422a
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.tar');
+$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/tar/files/frontcontroller12.phar.tar b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
new file mode 100644
index 0000000..e945e49
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller2.phar.inc b/ext/phar/tests/tar/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000..8ae1171
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.tar');
+$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/tar/files/frontcontroller2.phar.tar b/ext/phar/tests/tar/files/frontcontroller2.phar.tar
new file mode 100644
index 0000000..231e15a
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller2.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.inc b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000..800f65e
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.tar');
+$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/tar/files/frontcontroller3.phar.tar b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
new file mode 100644
index 0000000..16853bd
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.inc b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000..bfb9b41
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.tar');
+$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/tar/files/frontcontroller4.phar.tar b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
new file mode 100644
index 0000000..5a1d4ee
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller5.phar.inc b/ext/phar/tests/tar/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000..d6204c7
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.tar');
+$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/tar/files/frontcontroller5.phar.tar b/ext/phar/tests/tar/files/frontcontroller5.phar.tar
new file mode 100644
index 0000000..6053eb2
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller5.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller6.phar.inc b/ext/phar/tests/tar/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000..a5a6e30
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.tar');
+$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/tar/files/frontcontroller6.phar.tar b/ext/phar/tests/tar/files/frontcontroller6.phar.tar
new file mode 100644
index 0000000..eb3e44c
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller6.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller7.phar.inc b/ext/phar/tests/tar/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000..88121f5
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.tar');
+$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/tar/files/frontcontroller7.phar.tar b/ext/phar/tests/tar/files/frontcontroller7.phar.tar
new file mode 100644
index 0000000..b59d052
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller7.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller8.phar.inc b/ext/phar/tests/tar/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000..f51a762
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller8.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.tar');
+$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/tar/files/frontcontroller8.phar.tar b/ext/phar/tests/tar/files/frontcontroller8.phar.tar
new file mode 100644
index 0000000..3440a7f
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller8.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller9.phar.inc b/ext/phar/tests/tar/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000..758ce4f
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar.tar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.tar');
+$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/tar/files/frontcontroller9.phar.tar b/ext/phar/tests/tar/files/frontcontroller9.phar.tar
new file mode 100644
index 0000000..15e95b1
--- /dev/null
+++ b/ext/phar/tests/tar/files/frontcontroller9.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/links.phar.tar b/ext/phar/tests/tar/files/links.phar.tar
new file mode 100644
index 0000000..4646100
--- /dev/null
+++ b/ext/phar/tests/tar/files/links.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/links.tar b/ext/phar/tests/tar/files/links.tar
new file mode 100644
index 0000000..6cd22df
--- /dev/null
+++ b/ext/phar/tests/tar/files/links.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/make.dangerous.tar.php.inc b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc
new file mode 100644
index 0000000..deeaa41
--- /dev/null
+++ b/ext/phar/tests/tar/files/make.dangerous.tar.php.inc
@@ -0,0 +1,170 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+// this tarmaker makes a malicious tar with a header designed to overflow the buffer
+class danger_tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = @readlink($current);
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ '12345678', // have a mode that allows the name to overflow
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '123456789abc'); // malicious block
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, (binary)$fileOrStream);
+ if (strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/make_invalid_tar.php.inc b/ext/phar/tests/tar/files/make_invalid_tar.php.inc
new file mode 100644
index 0000000..413dd7b
--- /dev/null
+++ b/ext/phar/tests/tar/files/make_invalid_tar.php.inc
@@ -0,0 +1,9 @@
+<?php
+include dirname(__FILE__) . '/tarmaker.php.inc';
+class corrupter extends tarmaker {
+function close()
+{
+ fwrite($this->tmp, (binary)'oopsie');
+ fclose($this->tmp);
+}
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/subdirlink.tar b/ext/phar/tests/tar/files/subdirlink.tar
new file mode 100644
index 0000000..5463a49
--- /dev/null
+++ b/ext/phar/tests/tar/files/subdirlink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/tarmaker.php.inc b/ext/phar/tests/tar/files/tarmaker.php.inc
new file mode 100644
index 0000000..9b8d348
--- /dev/null
+++ b/ext/phar/tests/tar/files/tarmaker.php.inc
@@ -0,0 +1,169 @@
+<?php
+// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
+class tarmaker
+{
+ /**
+ * Path to archive file
+ *
+ * @var string
+ */
+ protected $archive;
+ /**
+ * Temporary stream used for creating the archive
+ *
+ * @var stream
+ */
+ protected $tmp;
+ protected $path;
+ protected $compress;
+ function __construct($path, $compress = 'zlib')
+ {
+ $this->compress = $compress;
+ if ($compress === 'bz2' && !function_exists('bzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'bzip2 extension not available');
+ }
+ if ($compress === 'zlib' && !function_exists('gzopen')) {
+ throw new PEAR2_Pyrus_Developer_Creator_Exception(
+ 'zlib extension not available');
+ }
+ $this->path = $path;
+ }
+
+ /**
+ * save a file inside this package
+ *
+ * This code is modified from Vincent Lascaux's File_Archive
+ * package, which is licensed under the LGPL license.
+ * @param string relative path within the package
+ * @param string|resource file contents or open file handle
+ */
+ function addFile($path, $fileOrStream, $stat = null)
+ {
+ clearstatcache();
+ if ($stat === null) {
+ if (is_resource($fileOrStream)) {
+ $stat = fstat($fileOrStream);
+ } else {
+ $stat = array(
+ 'mode' => 0x8000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => strlen($fileOrStream),
+ 'mtime' => time(),
+ );
+ }
+ }
+
+ $link = null;
+ if ($stat['mode'] & 0x4000) {
+ $type = 5; // Directory
+ } else if ($stat['mode'] & 0x8000) {
+ $type = 0; // Regular
+ } else if ($stat['mode'] & 0xA000) {
+ $type = 1; // Link
+ $link = @readlink($current);
+ } else {
+ $type = 9; // Unknown
+ }
+
+ $filePrefix = '';
+ if (strlen($path) > 255) {
+ throw new Exception(
+ "$path is too long, must be 255 characters or less"
+ );
+ } else if (strlen($path) > 100) {
+ $filePrefix = substr($path, 0, strlen($path)-100);
+ $path = substr($path, -100);
+ }
+
+ $block = pack('a100a8a8a8a12A12',
+ $path,
+ decoct($stat['mode']),
+ sprintf('%6s ',decoct($stat['uid'])),
+ sprintf('%6s ',decoct($stat['gid'])),
+ sprintf('%11s ',decoct($stat['size'])),
+ sprintf('%11s ',decoct($stat['mtime']))
+ );
+
+ $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
+ $type,
+ $link,
+ 'ustar',
+ '00',
+ 'Pyrus',
+ 'Pyrus',
+ '',
+ '',
+ $filePrefix,
+ '');
+
+ $checkheader = array_merge(str_split($block), str_split($blockend));
+ if (!function_exists('_pear2tarchecksum')) {
+ function _pear2tarchecksum($a, $b) {return $a + ord($b);}
+ }
+ $checksum = 256; // 8 * ord(' ');
+ $checksum += array_reduce($checkheader, '_pear2tarchecksum');
+
+ $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
+
+ fwrite($this->tmp, (binary)$block . $checksum . $blockend, 512);
+ if (is_resource($fileOrStream)) {
+ stream_copy_to_stream($fileOrStream, $this->tmp);
+ if ($stat['size'] % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - $stat['size'] % 512));
+ }
+ } else {
+ fwrite($this->tmp, (binary)$fileOrStream);
+ if (strlen($fileOrStream) % 512) {
+ fwrite($this->tmp, (binary)str_repeat("\0", 512 - strlen($fileOrStream) % 512));
+ }
+ }
+ }
+
+ /**
+ * Initialize the package creator
+ */
+ function init()
+ {
+ switch ($this->compress) {
+ case 'zlib' :
+ $this->tmp = gzopen($this->path, 'wb');
+ break;
+ case 'bz2' :
+ $this->tmp = bzopen($this->path, 'w');
+ break;
+ case 'none' :
+ $this->tmp = fopen($this->path, 'wb');
+ break;
+ default :
+ throw new Exception(
+ 'unknown compression type ' . $this->compress);
+ }
+ }
+
+ /**
+ * Create an internal directory, creating parent directories as needed
+ *
+ * @param string $dir
+ */
+ function mkdir($dir)
+ {
+ $this->addFile($dir, "", array(
+ 'mode' => 0x4000 + 0644,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'size' => 0,
+ 'mtime' => time(),
+ ));
+ }
+
+ /**
+ * Finish saving the package
+ */
+ function close()
+ {
+ fwrite($this->tmp, pack('a1024', ''));
+ fclose($this->tmp);
+ }
+} \ No newline at end of file
diff --git a/ext/phar/tests/tar/files/tinylink.tar b/ext/phar/tests/tar/files/tinylink.tar
new file mode 100644
index 0000000..741b56c
--- /dev/null
+++ b/ext/phar/tests/tar/files/tinylink.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/trunc.tar b/ext/phar/tests/tar/files/trunc.tar
new file mode 100644
index 0000000..2156b5c
--- /dev/null
+++ b/ext/phar/tests/tar/files/trunc.tar
Binary files differ