summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
authorSteph Fox <sfox@php.net>2008-08-31 20:54:28 +0000
committerSteph Fox <sfox@php.net>2008-08-31 20:54:28 +0000
commitcd011d1e9ab97f16770c7e8025406a3ca4d7c663 (patch)
tree128e887cc7c32cc72f9c654eaef77303e34ca9ab /ext/phar
parent76d758f736354de2e20251de9ece27b52675fd19 (diff)
downloadphp-git-cd011d1e9ab97f16770c7e8025406a3ca4d7c663.tar.gz
- MFB
Diffstat (limited to 'ext/phar')
-rw-r--r--ext/phar/config.w326
-rw-r--r--ext/phar/dirstream.c5
-rw-r--r--ext/phar/func_interceptors.c13
-rw-r--r--ext/phar/package.php10
-rw-r--r--ext/phar/package.xml234
-rw-r--r--ext/phar/phar.c134
-rwxr-xr-xext/phar/phar_internal.h1
-rwxr-xr-xext/phar/phar_object.c89
-rw-r--r--ext/phar/php_phar.h2
-rw-r--r--ext/phar/stream.c15
-rw-r--r--ext/phar/stream.h1
-rw-r--r--ext/phar/tar.c8
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller13.phar.inc14
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller14.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller16.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller17.phar.inc16
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller18.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller19.phar.inc25
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller8.phar.inc19
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/cache_list/files/md5.pharbin0 -> 107 bytes
-rw-r--r--ext/phar/tests/cache_list/files/nophar.pharbin0 -> 7049 bytes
-rw-r--r--ext/phar/tests/cache_list/files/nophar.phar.inc10
-rw-r--r--ext/phar/tests/cache_list/files/openssl.pharbin0 -> 6901 bytes
-rw-r--r--ext/phar/tests/cache_list/files/openssl.phar.pubkey6
-rw-r--r--ext/phar/tests/cache_list/files/phar_oo_test.inc49
-rw-r--r--ext/phar/tests/cache_list/files/phar_test.inc78
-rw-r--r--ext/phar/tests/cache_list/files/private.pem15
-rw-r--r--ext/phar/tests/cache_list/files/sha1.pharbin0 -> 111 bytes
-rw-r--r--ext/phar/tests/cache_list/files/sha256.pharbin0 -> 123 bytes
-rw-r--r--ext/phar/tests/cache_list/files/sha512.pharbin0 -> 155 bytes
-rw-r--r--ext/phar/tests/cache_list/files/zfapp.tgzbin0 -> 1725 bytes
-rw-r--r--ext/phar/tests/opendir_edgecases.phpt5
-rw-r--r--ext/phar/tests/phar_buildfromiterator10.phpt6
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_001.phpt9
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_001a.phpt9
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_002.phpt3
-rw-r--r--ext/phar/tests/phar_get_supported_signatures_002a.phpt9
-rw-r--r--ext/phar/tests/phpinfo_004.phpt2
-rw-r--r--ext/phar/tests/zip/bzip2.phpt80
-rw-r--r--ext/phar/tests/zip/files/bzip2.zipbin0 -> 603 bytes
-rw-r--r--ext/phar/util.c56
-rw-r--r--ext/phar/zip.c15
53 files changed, 933 insertions, 236 deletions
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
index 6632180649..e5a755084e 100644
--- a/ext/phar/config.w32
+++ b/ext/phar/config.w32
@@ -29,9 +29,11 @@ if (PHP_PHAR != "no") {
WARNING('Could not enable native OpenSSL support in Phar');
}
} else {
- /* If ext/openssl is built-in we can at least use the API directly */
- if (PHP_OPENSSL != "no" && !PHP_OPENSSL_SHARED) {
+ if (PHP_OPENSSL != "no" && !PHP_OPENSSL_SHARED && !PHP_PHAR_SHARED) {
AC_DEFINE('PHAR_HAVE_OPENSSL', 1);
+ STDOUT.WriteLine(' Native OpenSSL support in Phar enabled');
+ } else {
+ STDOUT.WriteLine(' Native OpenSSL support in Phar disabled');
}
}
ADD_EXTENSION_DEP('phar', 'spl', true);
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index e94a11a596..2e1754d6c8 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -569,7 +569,6 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
int arch_len, entry_len;
php_url *resource = NULL;
uint host_len;
- int key_type;
phar_zstr key;
char *str_key;
uint key_len;
@@ -641,7 +640,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
}
for (zend_hash_internal_pointer_reset(&phar->manifest);
- HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL));
+ HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL);
zend_hash_move_forward(&phar->manifest)) {
PHAR_STR(key, str_key);
@@ -661,7 +660,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
- HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL));
+ HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL);
zend_hash_move_forward(&phar->virtual_dirs)) {
PHAR_STR(key, str_key);
diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c
index 4daa1c982e..cf08cfd47c 100644
--- a/ext/phar/func_interceptors.c
+++ b/ext/phar/func_interceptors.c
@@ -517,7 +517,7 @@ void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_D
case S_IFDIR: RETURN_STRING("dir", 1);
case S_IFREG: RETURN_STRING("file", 1);
}
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%d)", stat_sb->st_mode&S_IFMT);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%u)", stat_sb->st_mode & S_IFMT);
RETURN_STRING("unknown", 1);
case FS_IS_W:
RETURN_BOOL((stat_sb->st_mode & wmask) != 0);
@@ -681,16 +681,12 @@ splitted:
#endif
goto statme_baby;
} else {
- char *save, *save2, *actual;
- int save_len, save2_len, actual_len;
+ char *save;
+ int save_len;
notfound:
save = PHAR_G(cwd);
- save2 = entry;
- actual = entry[0] == '/' ? (entry + 1) : entry;
save_len = PHAR_G(cwd_len);
- save2_len = entry_len;
- actual_len = entry[0] == '/' ? (entry_len - 1) : entry_len;
/* this file is not in the current directory, use the original path */
entry = estrndup(filename, filename_length);
entry_len = filename_length;
@@ -702,7 +698,6 @@ notfound:
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
- efree(save2);
if (IS_EXISTS_CHECK(type)) {
efree(arch);
RETURN_TRUE;
@@ -713,7 +708,6 @@ notfound:
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
- efree(save2);
efree(arch);
if (IS_EXISTS_CHECK(type)) {
RETURN_TRUE;
@@ -735,7 +729,6 @@ notfound:
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
- efree(save2);
efree(arch);
/* Error Occured */
if (!IS_EXISTS_CHECK(type)) {
diff --git a/ext/phar/package.php b/ext/phar/package.php
index d7d81e2e6a..53b6939050 100644
--- a/ext/phar/package.php
+++ b/ext/phar/package.php
@@ -8,8 +8,12 @@ BC BREAKING RELEASE
* phar.extract_list and Phar::getExtractList() are removed
Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
* new default stub allows running of phar-based phars without phar extension [Greg/Steph]
* add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
* add Phar::isFileFormat() [Greg]
* add Phar::convertToExecutable(), Phar::convertToData() [Greg]
* add Phar::compress() [Greg]
@@ -41,6 +45,10 @@ Security addition
Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
';
if (!class_exists("Phar") && !extension_loaded("Phar")) {
@@ -81,7 +89,7 @@ $options = array(
$package = PEAR_PackageFileManager2::importOptions(dirname(__FILE__) . '/package.xml', $options);
$package->clearDeps();
-$package->setPhpDep('5.2.0');
+$package->setPhpDep('5.2.1');
$package->setPearInstallerDep('1.4.3');
$package->addPackageDepWithChannel('optional', 'bz2', 'pecl.php.net', false, false, false, false, 'bz2');
// all this false business sets the <providesextension> tag that allows us to have hash built
diff --git a/ext/phar/package.xml b/ext/phar/package.xml
index d2d3dcdfd3..e4c2fe4f31 100644
--- a/ext/phar/package.xml
+++ b/ext/phar/package.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.7.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+<package packagerversion="1.7.2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>phar</name>
<channel>pecl.php.net</channel>
<summary>allows running of complete applications out of .phar files (like Java .jar files)</summary>
@@ -42,10 +42,10 @@ a 6x speedup measured running phpMyAdmin as a phar archive.</description>
<email>sfox@php.net</email>
<active>yes</active>
</developer>
- <date>2008-05-12</date>
- <time>15:42:58</time>
+ <date>2008-08-31</date>
+ <time>15:34:02</time>
<version>
- <release>2.0.0b1</release>
+ <release>2.0.0RC1</release>
<api>1.1.1</api>
</version>
<stability>
@@ -62,8 +62,12 @@ BC BREAKING RELEASE
* phar.extract_list and Phar::getExtractList() are removed
Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
* new default stub allows running of phar-based phars without phar extension [Greg/Steph]
* add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
* add Phar::isFileFormat() [Greg]
* add Phar::convertToExecutable(), Phar::convertToData() [Greg]
* add Phar::compress() [Greg]
@@ -95,6 +99,10 @@ Security addition
Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
</notes>
<contents>
@@ -109,7 +117,84 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="pharcommand.inc" role="src" />
</dir> <!-- /phar -->
<dir name="tests">
+ <dir name="cache_list">
+ <dir name="files">
+ <file name="frontcontroller.phar" role="test" />
+ <file name="frontcontroller.phar.inc" role="test" />
+ <file name="frontcontroller2.phar" role="test" />
+ <file name="frontcontroller2.phar.inc" role="test" />
+ <file name="frontcontroller3.phar" role="test" />
+ <file name="frontcontroller3.phar.inc" role="test" />
+ <file name="frontcontroller4.phar" role="test" />
+ <file name="frontcontroller4.phar.inc" role="test" />
+ <file name="frontcontroller5.phar" role="test" />
+ <file name="frontcontroller5.phar.inc" role="test" />
+ <file name="frontcontroller6.phar" role="test" />
+ <file name="frontcontroller6.phar.inc" role="test" />
+ <file name="frontcontroller7.phar" role="test" />
+ <file name="frontcontroller7.phar.inc" role="test" />
+ <file name="frontcontroller8.phar" role="test" />
+ <file name="frontcontroller8.phar.inc" role="test" />
+ <file name="frontcontroller9.phar" role="test" />
+ <file name="frontcontroller9.phar.inc" role="test" />
+ <file name="frontcontroller10.phar" role="test" />
+ <file name="frontcontroller10.phar.inc" role="test" />
+ <file name="frontcontroller11.phar" role="test" />
+ <file name="frontcontroller11.phar.inc" role="test" />
+ <file name="frontcontroller12.phar" role="test" />
+ <file name="frontcontroller12.phar.inc" role="test" />
+ <file name="frontcontroller13.phar" role="test" />
+ <file name="frontcontroller13.phar.inc" role="test" />
+ <file name="frontcontroller14.phar" role="test" />
+ <file name="frontcontroller14.phar.inc" role="test" />
+ <file name="frontcontroller16.phar" role="test" />
+ <file name="frontcontroller16.phar.inc" role="test" />
+ <file name="frontcontroller17.phar" role="test" />
+ <file name="frontcontroller17.phar.inc" role="test" />
+ <file name="frontcontroller18.phar" role="test" />
+ <file name="frontcontroller18.phar.inc" role="test" />
+ <file name="frontcontroller19.phar" role="test" />
+ <file name="frontcontroller19.phar.inc" role="test" />
+ </dir> <!-- /tests/cache_list/files -->
+ <file name="frontcontroller1.phpt" role="test" />
+ <file name="frontcontroller2.phpt" role="test" />
+ <file name="frontcontroller3.phpt" role="test" />
+ <file name="frontcontroller4.phpt" role="test" />
+ <file name="frontcontroller5.phpt" role="test" />
+ <file name="frontcontroller6.phpt" role="test" />
+ <file name="frontcontroller7.phpt" role="test" />
+ <file name="frontcontroller8.phpt" role="test" />
+ <file name="frontcontroller9.phpt" role="test" />
+ <file name="frontcontroller10.phpt" role="test" />
+ <file name="frontcontroller11.phpt" role="test" />
+ <file name="frontcontroller12.phpt" role="test" />
+ <file name="frontcontroller13.phpt" role="test" />
+ <file name="frontcontroller14.phpt" role="test" />
+ <file name="frontcontroller15.phpt" role="test" />
+ <file name="frontcontroller16.phpt" role="test" />
+ <file name="frontcontroller17.phpt" role="test" />
+ <file name="frontcontroller18.phpt" role="test" />
+ <file name="frontcontroller19.phpt" role="test" />
+ <file name="frontcontroller20.phpt" role="test" />
+ <file name="frontcontroller21.phpt" role="test" />
+ <file name="frontcontroller22.phpt" role="test" />
+ <file name="frontcontroller23.phpt" role="test" />
+ <file name="frontcontroller24.phpt" role="test" />
+ <file name="frontcontroller25.phpt" role="test" />
+ <file name="frontcontroller26.phpt" role="test" />
+ <file name="frontcontroller27.phpt" role="test" />
+ <file name="frontcontroller28.phpt" role="test" />
+ <file name="frontcontroller29.phpt" role="test" />
+ <file name="frontcontroller30.phpt" role="test" />
+ <file name="frontcontroller31.phpt" role="test" />
+ <file name="frontcontroller32.phpt" role="test" />
+ <file name="frontcontroller33.phpt" role="test" />
+ <file name="frontcontroller34.phpt" role="test" />
+ </dir> <!-- /tests/cache_list -->
<dir name="files">
+ <file name="blog.phar" role="test" />
+ <file name="blog.phar.inc" role="test" />
+ <file name="config.xml" role="test" />
<file name="extracted.inc" role="test" />
<file name="frontcontroller.phar" role="test" />
<file name="frontcontroller.phar.inc" role="test" />
@@ -150,8 +235,12 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="md5.phar" role="test" />
<file name="nophar.phar" role="test" />
<file name="nophar.phar.inc" role="test" />
+ <file name="notbogus.zip" role="test" />
+ <file name="openssl.phar" role="test" />
+ <file name="openssl.phar.pubkey" role="test" />
<file name="phar_oo_test.inc" role="test" />
<file name="phar_test.inc" role="test" />
+ <file name="private.pem" role="test" />
<file name="sha1.phar" role="test" />
<file name="sha256.phar" role="test" />
<file name="sha512.phar" role="test" />
@@ -200,6 +289,8 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="033.phpt" role="test" />
<file name="033a.phpt" role="test" />
<file name="alias_acrobatics.phpt" role="test" />
+ <file name="all.phpt" role="test" />
+ <file name="allU.phpt" role="test" />
<file name="badalias.phpt" role="test" />
<file name="badchecksum.phpt" role="test" />
<file name="bignames.phpt" role="test" />
@@ -239,11 +330,16 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="links5.phpt" role="test" />
<file name="open_for_write_existing.phpt" role="test" />
<file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
<file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
<file name="open_for_write_newfile.phpt" role="test" />
<file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
<file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
<file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
<file name="phar_buildfromiterator4.phpt" role="test" />
<file name="phar_buildfromiterator5.phpt" role="test" />
<file name="phar_buildfromiterator6.phpt" role="test" />
@@ -259,17 +355,24 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="phar_setalias.phpt" role="test" />
<file name="phar_setalias2.phpt" role="test" />
<file name="phar_setdefaultstub.phpt" role="test" />
+ <file name="phar_setsignaturealgo2.phpt" role="test" />
<file name="phar_stub.phpt" role="test" />
<file name="phar_stub_error.phpt" role="test" />
<file name="refcount1.phpt" role="test" />
<file name="refcount1_5_2.phpt" role="test" />
<file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="require_hash.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
<file name="tar_001.phpt" role="test" />
<file name="tar_002.phpt" role="test" />
<file name="tar_003.phpt" role="test" />
<file name="tar_004.phpt" role="test" />
+ <file name="tar_004U.phpt" role="test" />
<file name="tar_bz2.phpt" role="test" />
+ <file name="tar_bz2U.phpt" role="test" />
<file name="tar_gzip.phpt" role="test" />
+ <file name="tar_gzipU.phpt" role="test" />
<file name="tar_makebz2.phpt" role="test" />
<file name="tar_makegz.phpt" role="test" />
<file name="tar_nostub.phpt" role="test" />
@@ -282,6 +385,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="badalias3.phar.zip" role="test" />
<file name="badalias4.phar.zip" role="test" />
<file name="badalias5.phar.zip" role="test" />
+ <file name="bzip2.zip" role="test" />
<file name="cdir_offset.zip" role="test" />
<file name="compress_unsup1.zip" role="test" />
<file name="compress_unsup2.zip" role="test" />
@@ -299,11 +403,14 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="compress_unsup98.zip" role="test" />
<file name="compress_unsupunknown.zip" role="test" />
<file name="corrupt2.php.inc" role="test" />
+ <file name="corrupt3.php.inc" role="test" />
<file name="corrupt_count1.php.inc" role="test" />
<file name="corrupt_zipmaker.php.inc" role="test" />
<file name="count1.zip" role="test" />
<file name="count2.zip" role="test" />
+ <file name="disknumber.zip" role="test" />
<file name="encrypted.zip" role="test" />
+ <file name="extralen_toolong.zip" role="test" />
<file name="filecomment.zip" role="test" />
<file name="frontcontroller.phar.inc" role="test" />
<file name="frontcontroller.phar.zip" role="test" />
@@ -343,7 +450,9 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="033a.phpt" role="test" />
<file name="alias_acrobatics.phpt" role="test" />
<file name="all.phpt" role="test" />
+ <file name="allU.phpt" role="test" />
<file name="badalias.phpt" role="test" />
+ <file name="bzip2.phpt" role="test" />
<file name="corrupt_001.phpt" role="test" />
<file name="corrupt_002.phpt" role="test" />
<file name="corrupt_003.phpt" role="test" />
@@ -352,6 +461,8 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="corrupt_006.phpt" role="test" />
<file name="corrupt_007.phpt" role="test" />
<file name="corrupt_008.phpt" role="test" />
+ <file name="corrupt_009.phpt" role="test" />
+ <file name="corrupt_010.phpt" role="test" />
<file name="create_new_and_modify.phpt" role="test" />
<file name="create_new_phar_b.phpt" role="test" />
<file name="delete.phpt" role="test" />
@@ -384,15 +495,21 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="getalias.phpt" role="test" />
<file name="largezip.phpt" role="test" />
<file name="metadata_write_commit.phpt" role="test" />
+ <file name="metadata_write_commitU.phpt" role="test" />
<file name="notphar.phpt" role="test" />
<file name="odt.phpt" role="test" />
<file name="open_for_write_existing.phpt" role="test" />
<file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
<file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
<file name="open_for_write_newfile.phpt" role="test" />
<file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
<file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
<file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
<file name="phar_buildfromiterator4.phpt" role="test" />
<file name="phar_buildfromiterator5.phpt" role="test" />
<file name="phar_buildfromiterator6.phpt" role="test" />
@@ -403,6 +520,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="phar_convert_phar.phpt" role="test" />
<file name="phar_copy.phpt" role="test" />
<file name="phar_magic.phpt" role="test" />
+ <file name="phar_magicU.phpt" role="test" />
<file name="phar_oo_compressallbz2.phpt" role="test" />
<file name="phar_oo_compressallgz.phpt" role="test" />
<file name="phar_setalias.phpt" role="test" />
@@ -413,6 +531,8 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="refcount1.phpt" role="test" />
<file name="refcount1_5_2.phpt" role="test" />
<file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
<file name="unixzip.phpt" role="test" />
</dir> <!-- /tests/zip -->
<file name="001.phpt" role="test" />
@@ -435,10 +555,14 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="016.phpt" role="test" />
<file name="016b.phpt" role="test" />
<file name="017.phpt" role="test" />
+ <file name="017U.phpt" role="test" />
<file name="018.phpt" role="test" />
+ <file name="018U.phpt" role="test" />
<file name="019.phpt" role="test" />
<file name="019b.phpt" role="test" />
+ <file name="019bU.phpt" role="test" />
<file name="019c.phpt" role="test" />
+ <file name="019cU.phpt" role="test" />
<file name="020.phpt" role="test" />
<file name="021.phpt" role="test" />
<file name="022.phpt" role="test" />
@@ -447,6 +571,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="025.phpt" role="test" />
<file name="026.phpt" role="test" />
<file name="027.phpt" role="test" />
+ <file name="027U.phpt" role="test" />
<file name="028.phpt" role="test" />
<file name="029.phpt" role="test" />
<file name="030.phpt" role="test" />
@@ -459,6 +584,10 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="badparameters.phpt" role="test" />
<file name="bug13727.phpt" role="test" />
<file name="bug13786.phpt" role="test" />
+ <file name="bug45218_SLOWTEST.phpt" role="test" />
+ <file name="bug45218_SLOWTESTU.phpt" role="test" />
+ <file name="cached_manifest_1.phpt" role="test" />
+ <file name="cached_manifest_1U.phpt" role="test" />
<file name="create_new_and_modify.phpt" role="test" />
<file name="create_new_phar.phpt" role="test" />
<file name="create_new_phar_b.phpt" role="test" />
@@ -475,6 +604,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="fopen5.2.phpt" role="test" />
<file name="fopen_edgecases.phpt" role="test" />
<file name="fopen_edgecases2.phpt" role="test" />
+ <file name="front.phar.phpt" role="test" />
<file name="frontcontroller1.phpt" role="test" />
<file name="frontcontroller2.phpt" role="test" />
<file name="frontcontroller3.phpt" role="test" />
@@ -511,24 +641,34 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="frontcontroller34.phpt" role="test" />
<file name="include_path.phpt" role="test" />
<file name="ini_set.phpt" role="test" />
+ <file name="ini_setU.phpt" role="test" />
<file name="ini_set_off.phpt" role="test" />
+ <file name="ini_set_offU.phpt" role="test" />
<file name="invalid_alias.phpt" role="test" />
<file name="invalid_setstubalias.phpt" role="test" />
<file name="metadata_read.phpt" role="test" />
+ <file name="metadata_readU.phpt" role="test" />
<file name="metadata_write.phpt" role="test" />
+ <file name="metadata_writeU.phpt" role="test" />
<file name="metadata_write_commit.phpt" role="test" />
+ <file name="metadata_write_commitU.phpt" role="test" />
<file name="mkdir.phpt" role="test" />
<file name="mounteddir.phpt" role="test" />
+ <file name="mounteddirU.phpt" role="test" />
<file name="nophar.phpt" role="test" />
<file name="nophar_web.phpt" role="test" />
<file name="opendir.phpt" role="test" />
<file name="opendir_edgecases.phpt" role="test" />
<file name="open_for_write_existing.phpt" role="test" />
<file name="open_for_write_existing_b.phpt" role="test" />
+ <file name="open_for_write_existing_b_5_2.phpt" role="test" />
<file name="open_for_write_existing_c.phpt" role="test" />
+ <file name="open_for_write_existing_c_5_2.phpt" role="test" />
<file name="open_for_write_newfile.phpt" role="test" />
<file name="open_for_write_newfile_b.phpt" role="test" />
+ <file name="open_for_write_newfile_b_5_2.phpt" role="test" />
<file name="open_for_write_newfile_c.phpt" role="test" />
+ <file name="open_for_write_newfile_c_5_2.phpt" role="test" />
<file name="pharfileinfo_chmod.phpt" role="test" />
<file name="pharfileinfo_compression.phpt" role="test" />
<file name="pharfileinfo_construct.phpt" role="test" />
@@ -536,6 +676,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="pharfileinfo_getcrc32.phpt" role="test" />
<file name="pharfileinfo_setmetadata.phpt" role="test" />
<file name="phar_begin_setstub_commit.phpt" role="test" />
+ <file name="phar_begin_setstub_commitU.phpt" role="test" />
<file name="phar_buildfromdirectory1.phpt" role="test" />
<file name="phar_buildfromdirectory2.phpt" role="test" />
<file name="phar_buildfromdirectory3.phpt" role="test" />
@@ -552,7 +693,9 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="phar_buildfromiterator8.phpt" role="test" />
<file name="phar_buildfromiterator9.phpt" role="test" />
<file name="phar_buildfromiterator10.phpt" role="test" />
+ <file name="phar_buildfromiterator10U.phpt" role="test" />
<file name="phar_bz2.phpt" role="test" />
+ <file name="phar_bz2U.phpt" role="test" />
<file name="phar_commitwrite.phpt" role="test" />
<file name="phar_convert_again.phpt" role="test" />
<file name="phar_convert_repeated.phpt" role="test" />
@@ -567,26 +710,40 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="phar_ctx_001.phpt" role="test" />
<file name="phar_decompress.phpt" role="test" />
<file name="phar_dir_iterate.phpt" role="test" />
+ <file name="phar_dotted_path.phpt" role="test" />
<file name="phar_extract.phpt" role="test" />
+ <file name="phar_extract2.phpt" role="test" />
+ <file name="phar_extract3.phpt" role="test" />
<file name="phar_get_supportedcomp1.phpt" role="test" />
<file name="phar_get_supportedcomp2.phpt" role="test" />
<file name="phar_get_supportedcomp3.phpt" role="test" />
<file name="phar_get_supportedcomp4.phpt" role="test" />
<file name="phar_get_supported_signatures_001.phpt" role="test" />
+ <file name="phar_get_supported_signatures_001a.phpt" role="test" />
<file name="phar_get_supported_signatures_002.phpt" role="test" />
+ <file name="phar_get_supported_signatures_002a.phpt" role="test" />
<file name="phar_gobyebye.phpt" role="test" />
<file name="phar_gzip.phpt" role="test" />
+ <file name="phar_gzipU.phpt" role="test" />
<file name="phar_isvalidpharfilename.phpt" role="test" />
<file name="phar_magic.phpt" role="test" />
<file name="phar_metadata_read.phpt" role="test" />
+ <file name="phar_metadata_readU.phpt" role="test" />
<file name="phar_metadata_write.phpt" role="test" />
+ <file name="phar_metadata_writeU.phpt" role="test" />
<file name="phar_mount.phpt" role="test" />
+ <file name="phar_offset_check.phpt" role="test" />
<file name="phar_offset_get_error.phpt" role="test" />
<file name="phar_oo_001.phpt" role="test" />
+ <file name="phar_oo_001U.phpt" role="test" />
<file name="phar_oo_002.phpt" role="test" />
+ <file name="phar_oo_002U.phpt" role="test" />
<file name="phar_oo_003.phpt" role="test" />
<file name="phar_oo_004.phpt" role="test" />
+ <file name="phar_oo_004U.phpt" role="test" />
<file name="phar_oo_005.phpt" role="test" />
+ <file name="phar_oo_005U.phpt" role="test" />
+ <file name="phar_oo_005_5.2.phpt" role="test" />
<file name="phar_oo_006.phpt" role="test" />
<file name="phar_oo_007.phpt" role="test" />
<file name="phar_oo_008.phpt" role="test" />
@@ -629,6 +786,9 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<file name="refcount1.phpt" role="test" />
<file name="refcount1_5_2.phpt" role="test" />
<file name="rename.phpt" role="test" />
+ <file name="rename_dir.phpt" role="test" />
+ <file name="rename_dir_and_mount.phpt" role="test" />
+ <file name="rmdir.phpt" role="test" />
<file name="security.phpt" role="test" />
<file name="stat.phpt" role="test" />
<file name="stat2.phpt" role="test" />
@@ -676,7 +836,7 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<dependencies>
<required>
<php>
- <min>5.2.0</min>
+ <min>5.2.1</min>
</php>
<pearinstaller>
<min>1.4.3</min>
@@ -706,14 +866,14 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
<changelog>
<release>
<version>
- <release>2.0.0b1</release>
+ <release>2.0.0RC1</release>
<api>1.1.1</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
- <date>2008-05-12</date>
+ <date>2008-08-31</date>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
@@ -724,8 +884,12 @@ BC BREAKING RELEASE
* phar.extract_list and Phar::getExtractList() are removed
Major feature functionality release
+ * phar.cache_list allows web-based phar applications to run at equal or faster than
+ their on-disk equivalent [Greg]
* new default stub allows running of phar-based phars without phar extension [Greg/Steph]
* add support for tar-based and zip-based phar archives [Greg]
+ * add support for OpenSSL-based true signatures [Greg]
+ * add support for signatures to tar-based phar archives [Greg]
* add Phar::isFileFormat() [Greg]
* add Phar::convertToExecutable(), Phar::convertToData() [Greg]
* add Phar::compress() [Greg]
@@ -757,11 +921,67 @@ Security addition
Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
conversion API refactored
+Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
+ implement OpenSSL asynchronous true package signing
+ add support for package signing to tar-based archives
+ require PHP 5.2.1+
</notes>
</release>
<release>
<version>
+ <release>2.0.0b1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2008-05-12</date>
+ <license uri="http://www.php.net/license">PHP License</license>
+ <notes>BC BREAKING RELEASE
+ BC breaks:
+ * Phar object Compression API is rewritten. Use Phar::compress() and decompress(),
+ Phar::compressFiles()/decompressFiles() and PharFileInfo-&gt;compress()/decompress().
+ * phar.extract_list and Phar::getExtractList() are removed
+
+Major feature functionality release
+ * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
+ * add support for tar-based and zip-based phar archives [Greg]
+ * add Phar::isFileFormat() [Greg]
+ * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
+ * add Phar::compress() [Greg]
+ * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
+ decompressFiles() [Greg]
+ * conversion to compressed or to other file formats automatically copies the archive
+ to a new extension (i.e. &quot;.phar&quot; to &quot;.phar.tar&quot; or &quot;.tar&quot; to &quot;.tar.gz&quot;) [Steph]
+ * add Phar::webPhar() for running a web-based application unmodified
+ directly from a phar archive [Greg]
+ * file functions (fopen-based and stat-based) can be instructed to only look for
+ relative paths within a phar via Phar::interceptFileFuncs()
+ * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
+ non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
+ * paths with . and .. work (phar://blah.phar/a/../b.php =&gt; phar://blah.phar/b.php) [Greg]
+ * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
+ * add option to compress the entire phar file for phar/tar file format [Greg]
+ * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
+ * implement Phar::copy(string $from, string $to) [Greg]
+ * implement Phar::running(), returns path or URL to currently executed phar
+ * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
+ * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
+ * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
+ * add Phar::delete() [Greg]
+ * implement Phar::unlinkArchive() [Greg]
+
+Security addition
+ * aliases are validated so that they contain no directory separators as intended
+ * on conversion to other formats, user-supplied aliases are validated
+
+Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
+ conversion API refactored</notes>
+ </release>
+ <release>
+ <version>
<release>2.0.0a2</release>
<api>1.1.1</api>
</version>
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 36ec247b17..7102f23da1 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -2305,7 +2305,6 @@ int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_le
int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
{
char *fname;
- long halt_offset;
zval *halt_constant;
php_stream *fp;
int fname_len;
@@ -2340,7 +2339,6 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
return FAILURE;
}
- halt_offset = Z_LVAL(*halt_constant);
FREE_ZVAL(halt_constant);
#if PHP_MAJOR_VERSION < 6
@@ -2383,7 +2381,7 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
/**
* Validate the CRC32 of a file opened from within the phar
*/
-int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32, char **error TSRMLS_DC) /* {{{ */
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC) /* {{{ */
{
php_uint32 crc = ~0;
int len = idata->internal_file->uncompressed_filesize;
@@ -2394,7 +2392,7 @@ int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_d
*error = NULL;
}
- if (entry->is_zip) {
+ if (entry->is_zip && process_zip > 0) {
/* verify local file header */
phar_zip_file_header local;
@@ -2425,6 +2423,10 @@ int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_d
}
}
+ if (process_zip == 1) {
+ return SUCCESS;
+ }
+
php_stream_seek(fp, idata->zero, SEEK_SET);
while (len--) {
@@ -2437,7 +2439,7 @@ int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_d
entry->is_crc_checked = 1;
return SUCCESS;
} else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", idata->phar->fname, entry->filename);
+ spprintf(error, 0, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", idata->phar->fname, entry->filename);
return FAILURE;
}
}
@@ -2515,125 +2517,6 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz
}
/* }}} */
-#ifndef PHAR_HAVE_OPENSSL
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
-{
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
- zval *zdata, *zsig, *zkey, *retval_ptr, **zp[3], *openssl;
-
- MAKE_STD_ZVAL(zdata);
- MAKE_STD_ZVAL(openssl);
- ZVAL_STRINGL(openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1, 1);
- MAKE_STD_ZVAL(zsig);
- ZVAL_STRINGL(zsig, *signature, *signature_len, 1);
- MAKE_STD_ZVAL(zkey);
- ZVAL_STRINGL(zkey, key, key_len, 1);
- zp[0] = &zdata;
- zp[1] = &zsig;
- zp[2] = &zkey;
-
- php_stream_rewind(fp);
- Z_TYPE_P(zdata) = IS_STRING;
- Z_STRLEN_P(zdata) = end;
- if (end != (off_t) php_stream_copy_to_mem(fp, &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- return FAILURE;
- }
-
-#if PHP_VERSION_ID < 50300
- if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) {
-#else
- if (FAILURE == zend_fcall_info_init(openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
-#endif
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- zval_dtor(openssl);
- return FAILURE;
- }
-
- zval_dtor(openssl);
- efree(openssl);
-
- fci.param_count = 3;
- fci.params = zp;
-#if PHP_VERSION_ID < 50300
- ++(zdata->refcount);
- ++(zsig->refcount);
- ++(zkey->refcount);
-#else
- Z_ADDREF_P(zdata);
-
- if (is_sign) {
- Z_SET_ISREF_P(zsig);
- } else {
- Z_ADDREF_P(zsig);
- }
-
- Z_ADDREF_P(zkey);
-#endif
- fci.retval_ptr_ptr = &retval_ptr;
-
- if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
- zval_dtor(zdata);
- zval_dtor(zsig);
- zval_dtor(zkey);
- efree(zdata);
- efree(zkey);
- efree(zsig);
- return FAILURE;
- }
-#if PHP_VERSION_ID < 50300
- --(zdata->refcount);
- --(zsig->refcount);
- --(zkey->refcount);
-#else
- Z_DELREF_P(zdata);
-
- if (is_sign) {
- Z_UNSET_ISREF_P(zsig);
- } else {
- Z_DELREF_P(zsig);
- }
-
- Z_DELREF_P(zkey);
-#endif
- zval_dtor(zdata);
- efree(zdata);
- zval_dtor(zkey);
- efree(zkey);
-
- switch (Z_TYPE_P(retval_ptr)) {
- default:
- case IS_LONG:
- zval_dtor(zsig);
- efree(zsig);
- if (1 == Z_LVAL_P(retval_ptr)) {
- efree(retval_ptr);
- return SUCCESS;
- }
- efree(retval_ptr);
- return FAILURE;
- case IS_BOOL:
- efree(retval_ptr);
- if (Z_BVAL_P(retval_ptr)) {
- *signature = estrndup(Z_STRVAL_P(zsig), Z_STRLEN_P(zsig));
- *signature_len = Z_STRLEN_P(zsig);
- zval_dtor(zsig);
- efree(zsig);
- return SUCCESS;
- }
- zval_dtor(zsig);
- efree(zsig);
- return FAILURE;
- }
-}
-/* }}} */
-#endif /* #ifndef PHAR_HAVE_OPENSSL */
-
/**
* Save phar contents to disk
*
@@ -3302,7 +3185,6 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
}
if (phar->flags & PHAR_FILE_COMPRESSED_GZ) {
- php_stream_filter *filter;
/* to properly compress, we have to tell zlib to add a zlib header */
zval filterparams;
@@ -3326,8 +3208,6 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
/* use the temp stream as our base */
phar->fp = newfile;
} else if (phar->flags & PHAR_FILE_COMPRESSED_BZ2) {
- php_stream_filter *filter;
-
filter = php_stream_filter_create("bzip2.compress", NULL, php_stream_is_persistent(phar->fp) TSRMLS_CC);
php_stream_filter_append(&phar->fp->writefilters, filter);
php_stream_copy_to_stream(newfile, phar->fp, PHP_STREAM_COPY_ALL);
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index d97dee0adb..38b1e8816e 100755
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -576,6 +576,7 @@ void phar_object_init(TSRMLS_D);
void phar_destroy_phar_data(phar_archive_data *phar TSRMLS_DC);
int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
+int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error, int process_zip TSRMLS_DC);
int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index fe8eff2661..db82767e4f 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -203,7 +203,7 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
efree(ctr.line);
- ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %d", info->uncompressed_filesize);
+ ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
efree(ctr.line);
@@ -1393,7 +1393,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
{
zval **value;
zend_uchar key_type;
- zend_bool is_splfileinfo = 0, close_fp = 1;
+ zend_bool close_fp = 1;
ulong int_key;
struct _phar_t *p_obj = (struct _phar_t*) puser;
uint str_key_len, base_len = p_obj->l, fname_len;
@@ -1448,7 +1448,12 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
}
if (key_type > 9) { /* IS_UNICODE == 10 */
+#if PHP_VERSION_ID < 60000
+/* this can never happen, but fixes a compile warning */
+ spprintf(&str_key, 0, "%s", key);
+#else
spprintf(&str_key, 0, "%v", key);
+#endif
} else {
PHAR_STR(key, str_key);
}
@@ -1505,7 +1510,6 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
}
save = fname;
- is_splfileinfo = 1;
goto phar_spl_fileinfo;
case SPL_FS_INFO:
case SPL_FS_FILE:
@@ -1516,7 +1520,6 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
#endif
fname_len = strlen(fname);
save = fname;
- is_splfileinfo = 1;
goto phar_spl_fileinfo;
}
}
@@ -1577,7 +1580,12 @@ phar_spl_fileinfo:
}
if (key_type > 9) { /* IS_UNICODE == 10 */
+#if PHP_VERSION_ID < 60000
+/* this can never happen, but fixes a compile warning */
+ spprintf(&str_key, 0, "%s", key);
+#else
spprintf(&str_key, 0, "%v", key);
+#endif
} else {
PHAR_STR(key, str_key);
}
@@ -1986,6 +1994,7 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
char *error;
const char *pcr_error;
int ext_len = ext ? strlen(ext) : 0;
+ int oldname_len;
phar_archive_data **pphar = NULL;
if (!ext) {
@@ -2051,12 +2060,13 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
oldpath = estrndup(phar->fname, phar->fname_len);
oldname = zend_memrchr(phar->fname, '/', phar->fname_len);
++oldname;
+ oldname_len = strlen(oldname);
- basename = estrndup(oldname, strlen(oldname));
+ basename = estrndup(oldname, oldname_len);
spprintf(&newname, 0, "%s.%s", strtok(basename, "."), ext);
efree(basename);
- basepath = estrndup(oldpath, strlen(oldpath) - strlen(oldname));
+ basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len));
phar->fname_len = spprintf(&newpath, 0, "%s%s", basepath, newname);
phar->fname = newpath;
phar->ext = newpath + phar->fname_len - strlen(ext) - 1;
@@ -2986,7 +2996,7 @@ PHP_METHOD(Phar, getSignature)
add_assoc_stringl(return_value, "hash_type", "OpenSSL", 7, 1);
break;
default:
- unknown_len = spprintf(&unknown, 0, "Unknown (%d)", phar_obj->arc.archive->sig_flags);
+ unknown_len = spprintf(&unknown, 0, "Unknown (%u)", phar_obj->arc.archive->sig_flags);
add_assoc_stringl(return_value, "hash_type", unknown, unknown_len, 0);
break;
}
@@ -4638,7 +4648,6 @@ PHP_METHOD(PharFileInfo, compress)
case PHAR_ENT_COMPRESSED_GZ:
if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
RETURN_TRUE;
- return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
@@ -4670,7 +4679,6 @@ PHP_METHOD(PharFileInfo, compress)
case PHAR_ENT_COMPRESSED_BZ2:
if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
RETURN_TRUE;
- return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
@@ -4732,7 +4740,6 @@ PHP_METHOD(PharFileInfo, decompress)
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
RETURN_TRUE;
- return;
}
if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
@@ -4791,36 +4798,36 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, alias)
ZEND_ARG_INFO(0, fileformat)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_createDS, 0, 0, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, webindex)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_loadPhar, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, alias)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mapPhar, 0, 0, 0)
ZEND_ARG_INFO(0, alias)
ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mount, 0, 0, 2)
ZEND_ARG_INFO(0, inphar)
ZEND_ARG_INFO(0, externalfile)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mungServer, 0, 0, 1)
ZEND_ARG_INFO(0, munglist)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0)
@@ -4829,17 +4836,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0)
ZEND_ARG_INFO(0, f404)
ZEND_ARG_INFO(0, mimetypes)
ZEND_ARG_INFO(0, rewrites)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1)
ZEND_ARG_INFO(0, retphar)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_ua, 0, 0, 1)
ZEND_ARG_INFO(0, archive)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
#if HAVE_SPL
@@ -4847,114 +4854,114 @@ static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_build, 0, 0, 1)
ZEND_ARG_INFO(0, iterator)
ZEND_ARG_INFO(0, base_directory)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_conv, 0, 0, 0)
ZEND_ARG_INFO(0, format)
ZEND_ARG_INFO(0, compression_type)
ZEND_ARG_INFO(0, file_ext)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comps, 0, 0, 1)
ZEND_ARG_INFO(0, compression_type)
ZEND_ARG_INFO(0, file_ext)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_decomp, 0, 0, 0)
ZEND_ARG_INFO(0, file_ext)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comp, 0, 0, 1)
ZEND_ARG_INFO(0, compression_type)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_compo, 0, 0, 0)
ZEND_ARG_INFO(0, compression_type)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_copy, 0, 0, 2)
ZEND_ARG_INFO(0, newfile)
ZEND_ARG_INFO(0, oldfile)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_delete, 0, 0, 1)
ZEND_ARG_INFO(0, entry)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromdir, 0, 0, 1)
ZEND_ARG_INFO(0, base_dir)
ZEND_ARG_INFO(0, regex)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetExists, 0, 0, 1)
ZEND_ARG_INFO(0, entry)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, entry)
ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setAlias, 0, 0, 1)
ZEND_ARG_INFO(0, alias)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setMetadata, 0, 0, 1)
ZEND_ARG_INFO(0, metadata)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setSigAlgo, 0, 0, 1)
ZEND_ARG_INFO(0, algorithm)
ZEND_ARG_INFO(0, privatekey)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setStub, 0, 0, 1)
ZEND_ARG_INFO(0, newstub)
ZEND_ARG_INFO(0, maxlen)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_emptydir, 0, 0, 0)
ZEND_ARG_INFO(0, dirname)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_extract, 0, 0, 1)
ZEND_ARG_INFO(0, pathto)
ZEND_ARG_INFO(0, files)
ZEND_ARG_INFO(0, overwrite)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_addfile, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, localname)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_fromstring, 0, 0, 1)
ZEND_ARG_INFO(0, localname)
ZEND_ARG_INFO(0, contents)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isff, 0, 0, 1)
ZEND_ARG_INFO(0, fileformat)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
#endif /* HAVE_SPL */
@@ -5026,12 +5033,12 @@ zend_function_entry php_archive_methods[] = {
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry_chmod, 0, 0, 1)
ZEND_ARG_INFO(0, perms)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
zend_function_entry php_entry_methods[] = {
PHP_ME(PharFileInfo, __construct, arginfo_entry___construct, ZEND_ACC_PUBLIC)
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
index f0a34a2e01..374f7bbee1 100644
--- a/ext/phar/php_phar.h
+++ b/ext/phar/php_phar.h
@@ -22,7 +22,7 @@
#ifndef PHP_PHAR_H
#define PHP_PHAR_H
-#define PHP_PHAR_VERSION "2.0.0b2-dev"
+#define PHP_PHAR_VERSION "2.0.0RC2-dev"
#include "ext/standard/basic_functions.h"
extern zend_module_entry phar_module_entry;
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 3f2001d4bc..5ec6e2a86d 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -307,8 +307,9 @@ idata_error:
#endif
/* check length, crc32 */
- if (!idata->internal_file->is_crc_checked && phar_postprocess_file(wrapper, options, idata, idata->internal_file->crc32, &error TSRMLS_CC) != SUCCESS) {
- /* already issued the error */
+ if (!idata->internal_file->is_crc_checked && phar_postprocess_file(idata, idata->internal_file->crc32, &error, 2 TSRMLS_CC) != SUCCESS) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
+ efree(error);
phar_entry_delref(idata TSRMLS_CC);
efree(internal_file);
return NULL;
@@ -675,6 +676,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
{
php_url *resource;
char *internal_file, *error;
+ int internal_file_len;
phar_entry_data *idata;
phar_archive_data **pphar;
uint host_len;
@@ -700,7 +702,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
host_len = strlen(resource->host);
phar_request_initialize(TSRMLS_C);
- if (FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), resource->host, strlen(resource->host), (void **) &pphar)) {
+ if (FAILURE == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), resource->host, host_len, (void **) &pphar)) {
pphar = NULL;
}
if (PHAR_G(readonly) && (!pphar || !(*pphar)->is_data)) {
@@ -711,7 +713,8 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio
/* need to copy to strip leading "/", will get touched again */
internal_file = estrdup(resource->path + 1);
- if (FAILURE == phar_get_entry_data(&idata, resource->host, strlen(resource->host), internal_file, strlen(internal_file), "r", 0, &error, 1 TSRMLS_CC)) {
+ internal_file_len = strlen(internal_file);
+ if (FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, internal_file_len, "r", 0, &error, 1 TSRMLS_CC)) {
/* constraints of fp refcount were not met */
if (error) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "unlink of \"%s\" failed: %s", url, error);
@@ -828,7 +831,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
host_len = strlen(resource_from->host);
- if (SUCCESS != phar_get_archive(&phar, resource_from->host, strlen(resource_from->host), NULL, 0, &error TSRMLS_CC)) {
+ if (SUCCESS != phar_get_archive(&phar, resource_from->host, host_len, NULL, 0, &error TSRMLS_CC)) {
php_url_free(resource_from);
php_url_free(resource_to);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "phar error: cannot rename \"%s\" to \"%s\": %s", url_from, url_to, error);
@@ -909,6 +912,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
memcpy(new_str_key, resource_to->path + 1, to_len);
memcpy(new_str_key + to_len, str_key + from_len, key_len - from_len);
new_str_key[new_key_len] = 0;
+
is_modified = 1;
entry->is_modified = 1;
efree(entry->filename);
@@ -921,7 +925,6 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
#else
zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
#endif
- efree(new_str_key);
}
}
diff --git a/ext/phar/stream.h b/ext/phar/stream.h
index c69202bfcf..4029025cbd 100644
--- a/ext/phar/stream.h
+++ b/ext/phar/stream.h
@@ -20,7 +20,6 @@
/* $Id$ */
BEGIN_EXTERN_C()
-int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32, char **error TSRMLS_DC);
php_url* phar_parse_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC);
void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC);
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index e5159dab92..8a0ac07a80 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -255,7 +255,6 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
phar_tar_number(hdr->size, sizeof(hdr->size));
if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
- size_t read;
if (size > 511) {
if (error) {
spprintf(error, 4096, "phar error: tar-based phar \"%s\" has signature that is larger than 511 bytes, cannot process", fname);
@@ -291,7 +290,7 @@ bail:
}
/* signature checked out, let's ensure this is the last file in the phar */
size = ((size+511)&~511) + 512;
- if (((hdr->typeflag == 0) || (hdr->typeflag == TAR_FILE)) && size > 0) {
+ if (((hdr->typeflag == '\0') || (hdr->typeflag == TAR_FILE)) && size > 0) {
/* this is not good enough - seek succeeds even on truncated tars */
php_stream_seek(fp, size, SEEK_CUR);
if ((uint)php_stream_tell(fp) > totalsize) {
@@ -370,7 +369,7 @@ bail:
return FAILURE;
}
- entry.tar_type = ((old & (hdr->typeflag == 0))?'0':hdr->typeflag);
+ entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag);
entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */
entry.fp_type = PHAR_FP;
entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK;
@@ -424,7 +423,6 @@ bail:
}
if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
- size_t read;
/* found explicit alias */
if (size > 511) {
if (error) {
@@ -473,7 +471,7 @@ bail:
size = (size+511)&~511;
- if (((hdr->typeflag == 0) || (hdr->typeflag == TAR_FILE)) && size > 0) {
+ if (((hdr->typeflag == '\0') || (hdr->typeflag == TAR_FILE)) && size > 0) {
/* this is not good enough - seek succeeds even on truncated tars */
php_stream_seek(fp, size, SEEK_CUR);
if ((uint)php_stream_tell(fp) > totalsize) {
diff --git a/ext/phar/tests/cache_list/files/frontcontroller.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller.phar.inc
new file mode 100644
index 0000000000..80d42e886b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller.phar.inc
@@ -0,0 +1,13 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar');
+$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/cache_list/files/frontcontroller10.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc
new file mode 100644
index 0000000000..4c139db58b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller10.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller10.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar');
+$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/cache_list/files/frontcontroller11.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc
new file mode 100644
index 0000000000..086350800b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller11.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller11.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar');
+$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/cache_list/files/frontcontroller12.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
new file mode 100644
index 0000000000..ba17df37e1
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
@@ -0,0 +1,20 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller12.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar');
+$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"));
+Phar::webPhar();
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc
new file mode 100644
index 0000000000..0bfef46853
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller13.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller13.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller13.phar');
+$a['index.php'] = '<?php
+var_dump("test");
+include "oof/test.php";';
+$a['oof/test.php'] = '<?php
+var_dump("oof/test.php");
+include "./hi.php";';
+$a['oof/hi.php'] = '<?php
+var_dump("hi");';
+$a->setStub('<?php
+Phar::webPhar();
+__HALT_COMPILER();'); \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
new file mode 100644
index 0000000000..d0ebd9a45a
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller14.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller14.phar');
+$a['html/index.php'] = '<?php
+var_dump($_SERVER["PATH_INFO"]);
+var_dump($_SERVER["PATH_TRANSLATED"]);
+';
+$a->setStub('<?php
+function s($a)
+{
+ return "/html/index.php";
+}
+Phar::interceptFileFuncs();
+Phar::mungServer(array("PHP_SELF", "REQUEST_URI"));
+Phar::webPhar("whatever", "/html/index.php", null, array(), "s");
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc
new file mode 100644
index 0000000000..3c9986da00
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller16.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller16.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), array("fail", "here"));
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc
new file mode 100644
index 0000000000..85b8729f31
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller17.phar.inc
@@ -0,0 +1,16 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller17.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller17.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "sort");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc
new file mode 100644
index 0000000000..847a713ba3
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller18.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller18.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller18.phar');
+$a['index.php'] = '<?php
+echo "hi";
+';
+$a->setStub('<?php
+function s($a)
+{
+}
+try {
+Phar::webPhar("test.phar", "/index.php", null, array(), "s");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc
new file mode 100644
index 0000000000..ba84ac410a
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller19.phar.inc
@@ -0,0 +1,25 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller19.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller19.phar');
+$a['start/index.php'] = '<?php
+echo "start/index.php\n";
+include "./another.php";
+';
+$a['start/another.php'] = '<?php
+echo "start/another.php\n";
+include "../another.php";
+?>';
+$a['another.php'] = '<?php
+echo "another.php\n";
+?>';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__);
+try {
+Phar::webPhar("test.phar", "/start/index.php");
+} catch (Exception $e) {
+die($e->getMessage() . "\n");
+}
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc
new file mode 100644
index 0000000000..653c79691d
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller2.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller2.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar');
+$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/cache_list/files/frontcontroller3.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
new file mode 100644
index 0000000000..2759d9ee45
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller3.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array("/hi" => "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/cache_list/files/frontcontroller4.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
new file mode 100644
index 0000000000..5c6a43f954
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
@@ -0,0 +1,18 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller4.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+function s($a)
+{
+ static $b = array("/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/cache_list/files/frontcontroller5.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc
new file mode 100644
index 0000000000..d2d810c367
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller5.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller5.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar');
+$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/cache_list/files/frontcontroller6.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc
new file mode 100644
index 0000000000..5c900eb603
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller6.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller6.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("blah" => 100));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc
new file mode 100644
index 0000000000..684970263e
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller7.phar.inc
@@ -0,0 +1,12 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller7.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar');
+$a['a.php'] = 'hio';
+$a['a.jpg'] = 'hio';
+$a['a.phps'] = '<?php function hio(){}';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", null, array("blah" => null));
+echo "oops did not run\n";
+var_dump($_ENV, $_SERVER);
+__HALT_COMPILER();');
+?>
diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
new file mode 100644
index 0000000000..1dfb654a03
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
@@ -0,0 +1,19 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller8.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar');
+$a['a.phps'] = 'hio1';
+$a['a1.phps'] = '<?php var_dump($_SERVER["REQUEST_URI"], $_SERVER["PATH_INFO"]);';
+$a['a.jpg'] = 'hio2';
+$a['a.php'] = '<?php function hio(){}';
+$a['fronk.gronk'] = 'hio3';
+$a['404.php'] = 'My 404 is rawesome';
+$a['noext'] = 'hi';
+$a['unknown.ext'] = '<?php var_dump("hi");';
+$a['bigfile.txt'] = str_repeat('a', 8193);
+$a['fatalerror.phps'] = '<?php oopsie_daisy();';
+$a->setStub('<?php
+Phar::webPhar("whatever", "index.php", "404.php", 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/cache_list/files/frontcontroller9.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc
new file mode 100644
index 0000000000..00861f6420
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/frontcontroller9.phar.inc
@@ -0,0 +1,14 @@
+<?php
+@unlink(dirname(__FILE__) . '/frontcontroller9.phar');
+$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar');
+$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/cache_list/files/md5.phar b/ext/phar/tests/cache_list/files/md5.phar
new file mode 100644
index 0000000000..8ca2f84dac
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/md5.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/nophar.phar b/ext/phar/tests/cache_list/files/nophar.phar
new file mode 100644
index 0000000000..4eb3083c92
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/nophar.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/nophar.phar.inc b/ext/phar/tests/cache_list/files/nophar.phar.inc
new file mode 100644
index 0000000000..36d5628762
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/nophar.phar.inc
@@ -0,0 +1,10 @@
+<?php
+$fname = dirname(__FILE__) . '/nophar.phar';
+@unlink($fname);
+$p = new Phar($fname);
+$p['index.php'] = '<?php include "b/c.php";' . "\n";
+$p['web.php'] = '<?php echo "web\n";';
+$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("index.php", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
+$p['d'] = "in d\n";
+$p->setStub($p->createDefaultStub('index.php', 'web.php'));
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/openssl.phar b/ext/phar/tests/cache_list/files/openssl.phar
new file mode 100644
index 0000000000..f3864d7faa
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/openssl.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/openssl.phar.pubkey b/ext/phar/tests/cache_list/files/openssl.phar.pubkey
new file mode 100644
index 0000000000..7dd79ac2bf
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/openssl.phar.pubkey
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA3ADUiKZIEhekYShzPCZ3LFbg
+rDuV44jH94OdJQfqaCQBvZXqMoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzB
+mx9bFipOX2W2ouKS2YoHeIoR9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5
+agpkVsHLNJWbz/nPVwIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/cache_list/files/phar_oo_test.inc b/ext/phar/tests/cache_list/files/phar_oo_test.inc
new file mode 100644
index 0000000000..9863e8da93
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/phar_oo_test.inc
@@ -0,0 +1,49 @@
+<?php
+
+ini_set('date.timezone', 'GMT');
+
+$fname = dirname(__FILE__) . '/phar_oo_test.phar.php';
+$pname = 'phar://' . $fname;
+$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
+
+$files = array();
+
+if (!isset($pharconfig)) $pharconfig = 0;
+
+switch($pharconfig)
+{
+ default:
+ case 0:
+ $files['a.php'] = '<?php echo "This is a.php\n"; ?>';
+ $files['b.php'] = '<?php echo "This is b.php\n"; ?>';
+ $files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>';
+ $files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>';
+ $files['e.php'] = '<?php echo "This is e.php\n"; ?>';
+ break;
+ case 1:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+EOF;
+ break;
+ case 2:
+ $files['a.csv'] =<<<EOF
+1,2,3
+2,a,b
+3,"c","'e'"
+4
+5,5
+
+7,777
+EOF;
+ break;
+ case 3:
+ $files['a.php'] = '<?php echo new new class;';
+ break;
+}
+
+$ftime = mktime(12, 0, 0, 3, 1, 2006);
+include 'phar_test.inc';
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/phar_test.inc b/ext/phar/tests/cache_list/files/phar_test.inc
new file mode 100644
index 0000000000..f82471d13b
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/phar_test.inc
@@ -0,0 +1,78 @@
+<?php
+
+if (function_exists('date_default_timezone_set')) {
+ date_default_timezone_set('UTC');
+}
+
+$manifest = (binary)'';
+$glags = 0;
+
+foreach($files as $name => $cont)
+{
+ global $gflags, $files;
+
+ $comp = NULL;
+ $crc32= NULL;
+ $clen = NULL;
+ $ulen = NULL;
+ $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
+ $flags= 0;
+ $perm = 0x000001B6;
+ $meta = NULL;
+
+ // overwrite if array
+ if (is_array($cont))
+ {
+ foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what)
+ {
+ if (isset($cont[$what]))
+ {
+ $$what = $cont[$what];
+ }
+ }
+ }
+
+ // create if not yet done
+ if (empty($comp)) $comp = $cont;
+ if (empty($ulen)) $ulen = strlen($cont);
+ if (empty($clen)) $clen = strlen($comp);
+ if (empty($crc32))$crc32= crc32((binary)$cont);
+ if (isset($meta)) $meta = serialize($meta);
+
+ // write manifest entry
+ $manifest .= pack('V', strlen($name)) . (binary)$name;
+ $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . (binary)$meta;
+
+ // globals
+ $gflags |= $flags;
+ $files[$name] = $comp;
+}
+
+if (!isset($alias)) $alias = 'hio';
+
+if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
+
+$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags, strlen($alias)) . (binary)$alias . pack('V', strlen($pmeta)) . (binary)$pmeta . $manifest;
+$file = (binary)$file;
+$file .= pack('V', strlen($manifest)) . $manifest;
+
+foreach($files as $cont)
+{
+ $file .= (binary)$cont;
+}
+
+file_put_contents($fname, $file);
+
+if (@$gzip) {
+ $fp = gzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+if (@$bz2) {
+ $fp = bzopen($fname, 'w');
+ fwrite($fp, $file);
+ fclose($fp);
+}
+
+?> \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/private.pem b/ext/phar/tests/cache_list/files/private.pem
new file mode 100644
index 0000000000..e4f4883eb2
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/private.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDA3ADUiKZIEhekYShzPCZ3LFbgrDuV44jH94OdJQfqaCQBvZXq
+MoG1bWOeYfbc3iO0gHWW3SKB27Sf1ZBnc5c1+YzBmx9bFipOX2W2ouKS2YoHeIoR
+9leDNu4yqwBsuggFPGVPxM9ikEI+YAOGVTCd4mV5agpkVsHLNJWbz/nPVwIDAQAB
+AoGAGiS4qBbuE48ATXQuO5DH1hfYnxQ575Oskw7mdIL0k74SQ3ojvF+kXae6fVni
+UQZ76JgRWKYZa2kRDymwLZXpxVbiGL9dDvQY8ZENDtWOy9s7TDtxNixbZloKBopg
+J7G1B05LgetR3dgFnQOwt+e3kOu72RpS7thyBaUm8zHCRSECQQDw+h5uxE7i9CC8
+KHyJlwGoR28KZgrSpo74yWhQ+b1lzxQ+rk2wToFD/p+WNe/nf78YUl/cq0LngCKH
+Y7t228VLAkEAzOHzAjuDlGGzK6Kpe67iKgXd+GpKwPr9iaFfmzABOkRwQug4LCN7
+skmzCX5pzxqMZW1xNICjeDjWsMA3d4EypQJBAJyXPA1onYaXc2oxuPPD3/zVJpAQ
+TTojp8Z9Qr9T+kJdNV+h7rQB37gqjtOSiynY9nm8lbSUya4bstRd96S+HU8CQQCp
+yBAd6H2oZ7IXVeuHACyRUF1ab5LVCukxtVXJ/2T1CSPSfieWhC0MWMCR/HzoUALK
+RoBKVtOgW9GllRQh5yG1AkARVYbvj0XBy6XUpe5WZsLNWwpw1JreRsygcPXYh8bs
+nxhCdHNHJQ01lRDMjvNLtI8a5YjJE/IeW76T2mPCiJZI
+-----END RSA PRIVATE KEY-----
diff --git a/ext/phar/tests/cache_list/files/sha1.phar b/ext/phar/tests/cache_list/files/sha1.phar
new file mode 100644
index 0000000000..c7e9e7e6a2
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha1.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/sha256.phar b/ext/phar/tests/cache_list/files/sha256.phar
new file mode 100644
index 0000000000..81459eef0f
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha256.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/sha512.phar b/ext/phar/tests/cache_list/files/sha512.phar
new file mode 100644
index 0000000000..a7473819aa
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/sha512.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/zfapp.tgz b/ext/phar/tests/cache_list/files/zfapp.tgz
new file mode 100644
index 0000000000..fcaec86d65
--- /dev/null
+++ b/ext/phar/tests/cache_list/files/zfapp.tgz
Binary files differ
diff --git a/ext/phar/tests/opendir_edgecases.phpt b/ext/phar/tests/opendir_edgecases.phpt
index 9be23cbae1..c0f5ebc067 100644
--- a/ext/phar/tests/opendir_edgecases.phpt
+++ b/ext/phar/tests/opendir_edgecases.phpt
@@ -19,7 +19,12 @@ chdir(dirname(__FILE__));
$a = opendir('poo');
+$arr = array();
while (false !== ($b = readdir($a))) {
+ $arr[] = $b;
+}
+sort($arr);
+foreach ($arr as $b) {
echo "$b\n";
}
diff --git a/ext/phar/tests/phar_buildfromiterator10.phpt b/ext/phar/tests/phar_buildfromiterator10.phpt
index 8208cbd0ef..4dc3af7cca 100644
--- a/ext/phar/tests/phar_buildfromiterator10.phpt
+++ b/ext/phar/tests/phar_buildfromiterator10.phpt
@@ -30,7 +30,7 @@ unlink(dirname(__FILE__) . '/buildfromiterator.phar');
__HALT_COMPILER();
?>
--EXPECTF--
-array(33) {
+array(35) {
["phar_ctx_001.phpt"]=>
string(%d) "%sphar_ctx_001.phpt"
["phar_get_supported_signatures_001.phpt"]=>
@@ -97,5 +97,9 @@ array(33) {
string(%d) "%szip%ccorrupt_007.phpt"
["zip/corrupt_008.phpt"]=>
string(%d) "%szip%ccorrupt_008.phpt"
+ ["zip/corrupt_009.phpt"]=>
+ string(%d) "%szip%ccorrupt_009.phpt"
+ ["zip/corrupt_010.phpt"]=>
+ string(%d) "%szip%ccorrupt_010.phpt"
}
===DONE===
diff --git a/ext/phar/tests/phar_get_supported_signatures_001.phpt b/ext/phar/tests/phar_get_supported_signatures_001.phpt
index 794da6a942..64874f66e0 100644
--- a/ext/phar/tests/phar_get_supported_signatures_001.phpt
+++ b/ext/phar/tests/phar_get_supported_signatures_001.phpt
@@ -1,9 +1,12 @@
--TEST--
Phar::getSupportedSignatures()
--SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (extension_loaded("hash")) die("skip extension hash conflicts"); ?>
-<?php if (extension_loaded("openssl")) die("skip extension openssl loaded"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (extension_loaded("hash")) die("skip extension hash conflicts");
+$arr = Phar::getSupportedSignatures();
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
+?>
--INI--
phar.require_hash=0
phar.readonly=0
diff --git a/ext/phar/tests/phar_get_supported_signatures_001a.phpt b/ext/phar/tests/phar_get_supported_signatures_001a.phpt
index f267b48141..ad929df262 100644
--- a/ext/phar/tests/phar_get_supported_signatures_001a.phpt
+++ b/ext/phar/tests/phar_get_supported_signatures_001a.phpt
@@ -1,9 +1,12 @@
--TEST--
Phar::getSupportedSignatures()
--SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (extension_loaded("hash")) die("skip extension hash conflicts"); ?>
-<?php if (!extension_loaded("openssl")) die("skip extension openssl loaded"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (extension_loaded("hash")) die("skip extension hash conflicts");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+?>
--INI--
phar.require_hash=0
phar.readonly=0
diff --git a/ext/phar/tests/phar_get_supported_signatures_002.phpt b/ext/phar/tests/phar_get_supported_signatures_002.phpt
index fa9d02e584..d7cd350115 100644
--- a/ext/phar/tests/phar_get_supported_signatures_002.phpt
+++ b/ext/phar/tests/phar_get_supported_signatures_002.phpt
@@ -4,9 +4,8 @@ Phar::getSupportedSignatures()
<?php
if (!extension_loaded("phar")) die("skip");
if (!extension_loaded("hash")) die("skip extension hash required");
-if (extension_loaded("openssl")) die("skip extension openssl loaded");
$arr = Phar::getSupportedSignatures();
-if (in_array("OpenSSL", $arr)) die ("skip native openssl support enabled");
+if (in_array("OpenSSL", $arr)) die ("skip openssl support enabled");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_get_supported_signatures_002a.phpt b/ext/phar/tests/phar_get_supported_signatures_002a.phpt
index e4782e7ca0..ce907ff638 100644
--- a/ext/phar/tests/phar_get_supported_signatures_002a.phpt
+++ b/ext/phar/tests/phar_get_supported_signatures_002a.phpt
@@ -1,9 +1,12 @@
--TEST--
Phar::getSupportedSignatures()
--SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (!extension_loaded("hash")) die("skip extension hash required"); ?>
-<?php if (!extension_loaded("openssl")) die("skip extension openssl required"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+?>
--INI--
phar.require_hash=0
phar.readonly=0
diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt
index fd9f21882e..1ef795d5bf 100644
--- a/ext/phar/tests/phpinfo_004.phpt
+++ b/ext/phar/tests/phpinfo_004.phpt
@@ -6,7 +6,7 @@ if (!extension_loaded("phar")) die("skip");
if (!extension_loaded("zlib")) die("skip zlib not loaded");
if (!extension_loaded("bz2")) die("skip bz2 not loaded");
$arr = Phar::getSupportedSignatures();
-if (in_array("OpenSSL", $arr)) die("skip native openssl support enabled");
+if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
?>
--INI--
phar.readonly=0
diff --git a/ext/phar/tests/zip/bzip2.phpt b/ext/phar/tests/zip/bzip2.phpt
new file mode 100644
index 0000000000..f34f1859cd
--- /dev/null
+++ b/ext/phar/tests/zip/bzip2.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Phar: process bzip2-compressed zip entry
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("bz2")) die("skip bz2 not available"); ?>
+--FILE--
+<?php
+try {
+ $a = new PharData(dirname(__FILE__) . '/files/bzip2.zip');
+ foreach ($a as $entry => $file) {
+ echo $file->getContent();
+ }
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECT--
+<?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');
+?>
+===DONE===
diff --git a/ext/phar/tests/zip/files/bzip2.zip b/ext/phar/tests/zip/files/bzip2.zip
new file mode 100644
index 0000000000..2f27f027f5
--- /dev/null
+++ b/ext/phar/tests/zip/files/bzip2.zip
Binary files differ
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 008bd3f5ea..0723cd2508 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -254,7 +254,7 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
{
#if PHP_VERSION_ID >= 50300
char *path, *fname, *arch, *entry, *ret, *test;
- int arch_len, entry_len, fname_len;
+ int arch_len, entry_len, fname_len, ret_len;
phar_archive_data *phar;
if (pphar) {
@@ -322,9 +322,6 @@ splitted:
efree(path);
if (ret && strlen(ret) > 8 && !strncmp(ret, "phar://", 7)) {
- char *arch;
- int arch_len, ret_len;
-
ret_len = strlen(ret);
/* found phar:// */
@@ -475,7 +472,7 @@ not_stream:
wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
if (wrapper == &php_plain_files_wrapper) {
- strncpy(trypath, actual, MAXPATHLEN);
+ strlcpy(trypath, actual, sizeof(trypath));
} else if (!wrapper) {
/* if wrapper is NULL, there was a mal-formed include_path stream wrapper, so skip this ptr */
continue;
@@ -542,7 +539,7 @@ not_stream:
if (wrapper == &php_plain_files_wrapper) {
/* this should never technically happen, but we'll leave it here for completeness */
- strncpy(trypath, actual, MAXPATHLEN);
+ strlcpy(trypath, actual, sizeof(trypath));
} else if (!wrapper) {
/* if wrapper is NULL, there was a malformed include_path stream wrapper
this also should be impossible */
@@ -686,7 +683,7 @@ really_get_entry:
if (entry->link) {
efree(entry->link);
entry->link = NULL;
- entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
}
if (for_write) {
@@ -740,7 +737,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char
phar_unixify_path_separators(path, path_len);
#endif
- is_dir = (path_len > 0 && path != NULL) ? path[path_len - 1] == '/' : 0;
+ is_dir = (path_len && path[path_len - 1] == '/') ? 1 : 0;
if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
return NULL;
@@ -877,7 +874,7 @@ int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **er
if (dest->link) {
efree(dest->link);
dest->link = NULL;
- dest->tar_type = (dest->tar_type ? TAR_FILE : 0);
+ dest->tar_type = (dest->is_tar ? TAR_FILE : '\0');
}
dest->fp_type = PHAR_MOD;
@@ -913,6 +910,7 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
char *filtername;
off_t loc;
php_stream *ufp;
+ phar_entry_data dummy;
if (follow_links && entry->link) {
phar_entry_info *link_entry = phar_get_link_source(entry TSRMLS_CC);
@@ -921,6 +919,10 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
}
}
+ if (entry->is_modified) {
+ return SUCCESS;
+ }
+
if (entry->fp_type == PHAR_TMP) {
if (!entry->fp) {
entry->fp = php_stream_open_wrapper(entry->tmp, "rb", STREAM_MUST_SEEK|0, NULL);
@@ -941,6 +943,13 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
}
if ((entry->old_flags && !(entry->old_flags & PHAR_ENT_COMPRESSION_MASK)) || !(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {
+ dummy.internal_file = entry;
+ dummy.phar = phar;
+ dummy.zero = entry->offset;
+ dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
return SUCCESS;
}
@@ -952,6 +961,14 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
}
}
+ dummy.internal_file = entry;
+ dummy.phar = phar;
+ dummy.zero = entry->offset;
+ dummy.fp = phar_get_pharfp(phar TSRMLS_CC);
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 1 TSRMLS_CC)) {
+ return FAILURE;
+ }
+
ufp = phar_get_entrypufp(entry TSRMLS_CC);
if ((filtername = phar_decompress_filter(entry, 0)) != NULL) {
@@ -991,6 +1008,11 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
/* this is now the new location of the file contents within this fp */
phar_set_fp_type(entry, PHAR_UFP, loc TSRMLS_CC);
+ dummy.zero = entry->offset;
+ dummy.fp = ufp;
+ if (FAILURE == phar_postprocess_file(&dummy, entry->crc32, error, 0 TSRMLS_CC)) {
+ return FAILURE;
+ }
return SUCCESS;
}
/* }}} */
@@ -1057,7 +1079,7 @@ int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry,
if (entry->link) {
efree(entry->link);
entry->link = NULL;
- entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
}
entry->fp = php_stream_fopen_tmpfile();
@@ -1114,7 +1136,7 @@ int phar_separate_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC) /* {{
if (entry->link) {
efree(entry->link);
entry->link = NULL;
- entry->tar_type = (entry->tar_type ? TAR_FILE : 0);
+ entry->tar_type = (entry->is_tar ? TAR_FILE : '\0');
}
entry->offset = 0;
@@ -1434,7 +1456,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
phar_unixify_path_separators(path, path_len);
#endif
- is_dir = path_len && (path[path_len - 1] == '/');
+ is_dir = (path_len && (path[path_len - 1] == '/')) ? 1 : 0;
if (error) {
*error = NULL;
@@ -1525,7 +1547,6 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
} else {
char *test;
int test_len;
- phar_entry_info *entry;
php_stream_statbuf ssb;
if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
@@ -1638,6 +1659,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
zval_dtor(zkey);
return FAILURE;
}
+
#if PHP_VERSION_ID < 50300
if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) {
#else
@@ -1655,7 +1677,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
fci.params = zp;
#if PHP_VERSION_ID < 50300
++(zdata->refcount);
- ++(zsig->refcount);
+ if (!is_sign) {
+ ++(zsig->refcount);
+ }
++(zkey->refcount);
#else
Z_ADDREF_P(zdata);
@@ -1684,7 +1708,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
efree(openssl);
#if PHP_VERSION_ID < 50300
--(zdata->refcount);
- --(zsig->refcount);
+ if (!is_sign) {
+ --(zsig->refcount);
+ }
--(zkey->refcount);
#else
Z_DELREF_P(zdata);
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 07725875f4..26d873239f 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -159,7 +159,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
phar_zip_dir_end locator;
char buf[sizeof(locator) + 65536];
long size;
- size_t read;
php_uint16 i;
phar_archive_data *mydata = NULL;
phar_entry_info entry = {0};
@@ -181,7 +180,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
php_stream_seek(fp, 0, SEEK_SET);
}
- if (!(read = php_stream_read(fp, buf, size))) {
+ if (!php_stream_read(fp, buf, size)) {
php_stream_close(fp);
if (error) {
spprintf(error, 4096, "phar error: unable to read in data to search for end of central directory in zip-based phar \"%s\"", fname);
@@ -491,7 +490,6 @@ foundit:
php_stream_filter_remove(filter, 1 TSRMLS_CC);
} else if (entry.flags & PHAR_ENT_COMPRESSED_BZ2) {
- php_stream_filter *filter;
filter = php_stream_filter_create("bzip2.decompress", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
if (!filter) {
@@ -655,6 +653,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
struct _phar_zip_pass *p;
php_uint32 newcrc32;
off_t offset;
+ int not_really_modified = 0;
entry = (phar_entry_info *)data;
p = (struct _phar_zip_pass*) arg;
@@ -723,6 +722,12 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
return ZEND_HASH_APPLY_STOP;
}
+ /* we can be modified and already be compressed, such as when chmod() is executed */
+ if (entry->flags & PHAR_ENT_COMPRESSION_MASK && (entry->old_flags == entry->flags || !entry->old_flags)) {
+ not_really_modified = 1;
+ goto is_compressed;
+ }
+
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) {
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
@@ -791,6 +796,7 @@ static int phar_zip_changed_apply(void *data, void *arg TSRMLS_DC) /* {{{ */
entry->old_flags = entry->flags;
entry->is_modified = 1;
} else {
+is_compressed:
central.uncompsize = local.uncompsize = PHAR_SET_32(entry->uncompressed_filesize);
central.compsize = local.compsize = PHAR_SET_32(entry->compressed_filesize);
@@ -872,7 +878,7 @@ continue_dir:
return ZEND_HASH_APPLY_STOP;
}
- if (entry->is_modified) {
+ if (!not_really_modified && entry->is_modified) {
if (entry->cfp) {
if (entry->compressed_filesize != php_stream_copy_to_stream(entry->cfp, p->filefp, entry->compressed_filesize)) {
spprintf(p->error, 0, "unable to write compressed contents of file \"%s\" in zip-based phar \"%s\"", entry->filename, entry->phar->fname);
@@ -900,6 +906,7 @@ continue_dir:
entry->is_modified = 0;
} else {
+ entry->is_modified = 0;
if (entry->fp_refcount) {
/* open file pointers refer to this fp, do not free the stream */
switch (entry->fp_type) {