summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2010-01-07 13:31:53 +0100
committerOndřej Surý <ondrej@sury.org>2010-01-07 13:31:53 +0100
commit0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch)
tree91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/phar
parentd3a8757891280dc6650ca7eead67830c794b0e7b (diff)
downloadphp-upstream/5.3.1.tar.gz
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/phar')
-rwxr-xr-xext/phar/Makefile.frag5
-rw-r--r--ext/phar/config.m42
-rw-r--r--ext/phar/config.w322
-rw-r--r--ext/phar/dirstream.c14
-rw-r--r--ext/phar/dirstream.h2
-rw-r--r--ext/phar/func_interceptors.c2
-rw-r--r--ext/phar/func_interceptors.h2
-rw-r--r--ext/phar/makestub.php2
-rw-r--r--ext/phar/package.php29
-rw-r--r--ext/phar/package.xml367
-rw-r--r--ext/phar/phar.c34
-rwxr-xr-xext/phar/phar/directorygraphiterator.inc66
-rwxr-xr-xext/phar/phar/directorytreeiterator.inc106
-rwxr-xr-xext/phar/phar/invertedregexiterator.inc52
-rwxr-xr-xext/phar/phar/pharcommand.inc2
-rwxr-xr-xext/phar/phar_internal.h37
-rwxr-xr-xext/phar/phar_object.c214
-rwxr-xr-xext/phar/phar_path_check.c2
-rwxr-xr-xext/phar/phar_path_check.re2
-rw-r--r--ext/phar/pharzip.h3
-rw-r--r--ext/phar/php_phar.h4
-rw-r--r--ext/phar/stream.c18
-rw-r--r--ext/phar/stream.h2
-rw-r--r--ext/phar/stub.h2
-rw-r--r--ext/phar/tar.c86
-rw-r--r--ext/phar/tests/009.phpt2
-rw-r--r--ext/phar/tests/016.phpt6
-rw-r--r--ext/phar/tests/badparameters.phpt6
-rw-r--r--ext/phar/tests/bug46032.phpt8
-rw-r--r--ext/phar/tests/bug48377.2.phpt25
-rw-r--r--ext/phar/tests/bug48377.phpt29
-rw-r--r--ext/phar/tests/cache_list/copyonwrite17.phar.phpt2
-rw-r--r--ext/phar/tests/cache_list/copyonwrite19.phar.phpt2
-rw-r--r--ext/phar/tests/cache_list/copyonwrite6.phar.phpt1
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller12.pharbin581 -> 588 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller12.phar.inc14
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller14.pharbin448 -> 450 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller14.phar.inc4
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller3.pharbin446 -> 437 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller3.phar.inc2
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller4.pharbin442 -> 433 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller4.phar.inc2
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller8.pharbin8968 -> 8970 bytes
-rw-r--r--ext/phar/tests/cache_list/files/frontcontroller8.phar.inc2
-rw-r--r--ext/phar/tests/cache_list/files/write24.pharbin326 -> 327 bytes
-rw-r--r--ext/phar/tests/cache_list/files/write24.phar.inc2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller21.phpt2
-rw-r--r--ext/phar/tests/cache_list/frontcontroller22.phpt4
-rwxr-xr-xext/phar/tests/create_new_and_modify.phpt6
-rw-r--r--ext/phar/tests/files/frontcontroller12.pharbin581 -> 588 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller12.phar.inc14
-rw-r--r--ext/phar/tests/files/frontcontroller14.pharbin448 -> 450 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller14.phar.inc4
-rw-r--r--ext/phar/tests/files/frontcontroller3.pharbin446 -> 438 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller3.phar.inc2
-rw-r--r--ext/phar/tests/files/frontcontroller4.pharbin442 -> 433 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller4.phar.inc2
-rw-r--r--ext/phar/tests/files/frontcontroller8.pharbin8968 -> 8970 bytes
-rw-r--r--ext/phar/tests/files/frontcontroller8.phar.inc2
-rw-r--r--ext/phar/tests/fopen_edgecases2.phpt7
-rw-r--r--ext/phar/tests/fopen_edgecases2U.phpt46
-rw-r--r--ext/phar/tests/frontcontroller21.phpt2
-rw-r--r--ext/phar/tests/frontcontroller22.phpt4
-rw-r--r--ext/phar/tests/ini_set.phpt19
-rw-r--r--ext/phar/tests/ini_setU.phpt31
-rw-r--r--ext/phar/tests/phar_buildfromiterator10.phpt1
-rw-r--r--ext/phar/tests/phar_buildfromiterator10U.phpt101
-rw-r--r--ext/phar/tests/phar_bz2.phpt5
-rw-r--r--ext/phar/tests/phar_bz2U.phpt66
-rw-r--r--ext/phar/tests/phar_convert_again.phpt6
-rw-r--r--ext/phar/tests/phar_ctx_001.phpt2
-rw-r--r--ext/phar/tests/phar_magic.phpt3
-rw-r--r--ext/phar/tests/readfile_edgecases.phpt1
-rw-r--r--ext/phar/tests/readfile_edgecasesU.phpt61
-rw-r--r--ext/phar/tests/tar/bignames.phpt28
-rw-r--r--ext/phar/tests/tar/bignames_overflow.phpt8
-rw-r--r--ext/phar/tests/tar/bug49910.phpt50
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgzbin0 -> 1284 bytes
-rw-r--r--ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey9
-rw-r--r--ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgzbin0 -> 30191 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.inc14
-rw-r--r--ext/phar/tests/tar/files/frontcontroller12.phar.tarbin4096 -> 4096 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.inc2
-rw-r--r--ext/phar/tests/tar/files/frontcontroller3.phar.tarbin6144 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.inc2
-rw-r--r--ext/phar/tests/tar/files/frontcontroller4.phar.tarbin6144 -> 6144 bytes
-rw-r--r--ext/phar/tests/tar/frontcontroller21.phar.phpt2
-rw-r--r--ext/phar/tests/tar/phar_convert_phar4.phpt2
-rw-r--r--ext/phar/tests/tar/phar_magic.phpt3
-rw-r--r--ext/phar/tests/tar/tar_openssl_hash.phpt22
-rw-r--r--ext/phar/tests/zip/all.phpt1
-rw-r--r--ext/phar/tests/zip/bug48791.phpt15
-rw-r--r--ext/phar/tests/zip/files/corrupt_zipmaker.php.inc2
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.inc14
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.zipbin786 -> 793 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.inc2
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.zipbin816 -> 818 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.inc2
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.zipbin812 -> 813 bytes
-rw-r--r--ext/phar/tests/zip/files/test.odtbin0 -> 8303 bytes
-rw-r--r--ext/phar/tests/zip/frontcontroller21.phar.phpt2
-rw-r--r--ext/phar/tests/zip/phar_magic.phpt3
-rw-r--r--ext/phar/tests/zip/phar_setsignaturealgo2.phpt113
-rw-r--r--ext/phar/util.c25
-rw-r--r--ext/phar/zip.c196
105 files changed, 1571 insertions, 501 deletions
diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag
index 554bc0cdf..076ce8a93 100755
--- a/ext/phar/Makefile.frag
+++ b/ext/phar/Makefile.frag
@@ -37,10 +37,11 @@ $(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/
-@echo "Generating phar.phar"
-@rm -f $(builddir)/phar.phar
-@rm -f $(srcdir)/phar.phar
- @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x CVS -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
+ @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
-@chmod +x $(builddir)/phar.phar
install-pharcmd: pharcmd
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)
- $(LN_S) -f $(INSTALL_ROOT)$(bindir)/phar.phar $(INSTALL_ROOT)$(bindir)/phar
+ -@rm -f $(INSTALL_ROOT)$(bindir)/phar
+ $(LN_S) -f $(bindir)/phar.phar $(INSTALL_ROOT)$(bindir)/phar
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
index 42b55bb1b..70b03a2c9 100644
--- a/ext/phar/config.m4
+++ b/ext/phar/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.27.2.13 2009/02/16 16:41:40 cellog Exp $
+dnl $Id: config.m4 275933 2009-02-16 16:41:40Z cellog $
dnl config.m4 for extension phar
PHP_ARG_ENABLE(phar, for phar archive support,
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
index c61ed6cfa..c117cc147 100644
--- a/ext/phar/config.w32
+++ b/ext/phar/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.27.2.10 2009/05/11 06:43:05 kalle Exp $
+// $Id: config.w32 280331 2009-05-11 06:43:05Z kalle $
// vim:ft=javascript
ARG_ENABLE("phar", "disable phar support", "yes");
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index f466b4a13..c1758d420 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -112,11 +112,13 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
to_read = MIN(keylen, count);
if (to_read == 0 || count < keylen) {
+ PHAR_STR_FREE(str_key);
return 0;
}
memset(buf, 0, sizeof(php_stream_dirent));
memcpy(((php_stream_dirent *) buf)->d_name, str_key, to_read);
+ PHAR_STR_FREE(str_key);
((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
return sizeof(php_stream_dirent);
@@ -217,6 +219,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
if (keylen <= (uint)dirlen) {
if (keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) {
+ PHAR_STR_FREE(str_key);
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
@@ -227,6 +230,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
if (*dir == '/') {
/* root directory */
if (keylen >= sizeof(".phar")-1 && !memcmp(str_key, ".phar", sizeof(".phar")-1)) {
+ PHAR_STR_FREE(str_key);
/* do not add any magic entries to this directory */
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
@@ -246,16 +250,19 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
entry[keylen] = '\0';
}
+ PHAR_STR_FREE(str_key);
goto PHAR_ADD_ENTRY;
} else {
if (0 != memcmp(str_key, dir, dirlen)) {
/* entry in directory not found */
+ PHAR_STR_FREE(str_key);
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
continue;
} else {
if (str_key[dirlen] != '/') {
+ PHAR_STR_FREE(str_key);
if (SUCCESS != zend_hash_move_forward(manifest)) {
break;
}
@@ -282,6 +289,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
entry[keylen - dirlen - 1] = '\0';
keylen = keylen - dirlen - 1;
}
+ PHAR_STR_FREE(str_key);
PHAR_ADD_ENTRY:
if (keylen) {
phar_add_empty(data, entry, keylen);
@@ -400,12 +408,14 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
&phar->manifest, &key, &keylen, &unused, 0, NULL)) {
PHAR_STR(key, str_key);
if (keylen > (uint)i_len && 0 == memcmp(str_key, internal_file, i_len)) {
+ PHAR_STR_FREE(str_key);
/* directory found */
internal_file = estrndup(internal_file,
i_len);
php_url_free(resource);
return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
}
+ PHAR_STR_FREE(str_key);
}
if (SUCCESS != zend_hash_move_forward(&phar->manifest)) {
@@ -635,6 +645,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
if (key_len > path_len &&
memcmp(str_key, resource->path+1, path_len) == 0 &&
IS_SLASH(str_key[path_len])) {
+ PHAR_STR_FREE(str_key);
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
if (entry->is_temp_dir) {
efree(entry->filename);
@@ -643,6 +654,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
php_url_free(resource);
return 0;
}
+ PHAR_STR_FREE(str_key);
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
@@ -654,6 +666,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
if (key_len > path_len &&
memcmp(str_key, resource->path+1, path_len) == 0 &&
IS_SLASH(str_key[path_len])) {
+ PHAR_STR_FREE(str_key);
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: Directory not empty");
if (entry->is_temp_dir) {
efree(entry->filename);
@@ -662,6 +675,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
php_url_free(resource);
return 0;
}
+ PHAR_STR_FREE(str_key);
}
}
diff --git a/ext/phar/dirstream.h b/ext/phar/dirstream.h
index f7d73bfb8..e7bb4ae68 100644
--- a/ext/phar/dirstream.h
+++ b/ext/phar/dirstream.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dirstream.h,v 1.5.2.3 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: dirstream.h 272370 2008-12-31 11:15:49Z sebastian $ */
BEGIN_EXTERN_C()
int phar_wrapper_mkdir(php_stream_wrapper *wrapper, char *url_from, int mode, int options, php_stream_context *context TSRMLS_DC);
diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c
index 224b0a2ba..199509b5e 100644
--- a/ext/phar/func_interceptors.c
+++ b/ext/phar/func_interceptors.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: func_interceptors.c,v 1.20.2.22 2009/05/13 15:55:12 kalle Exp $ */
+/* $Id: func_interceptors.c 280454 2009-05-13 15:55:12Z kalle $ */
#include "phar_internal.h"
diff --git a/ext/phar/func_interceptors.h b/ext/phar/func_interceptors.h
index 0fc82b4eb..1b4c623b5 100644
--- a/ext/phar/func_interceptors.h
+++ b/ext/phar/func_interceptors.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: func_interceptors.h,v 1.1.2.4 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: func_interceptors.h 272370 2008-12-31 11:15:49Z sebastian $ */
BEGIN_EXTERN_C()
void phar_intercept_functions(TSRMLS_D);
diff --git a/ext/phar/makestub.php b/ext/phar/makestub.php
index eb089af77..43298c99a 100644
--- a/ext/phar/makestub.php
+++ b/ext/phar/makestub.php
@@ -48,7 +48,7 @@ $stub = '/*
+----------------------------------------------------------------------+
*/
-/* $Id: makestub.php,v 1.7.2.2 2008/08/01 13:48:44 sfox Exp $ */
+/* $Id: makestub.php 264018 2008-08-01 13:48:45Z sfox $ */
static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
{
diff --git a/ext/phar/package.php b/ext/phar/package.php
index 53b693905..181c7c45f 100644
--- a/ext/phar/package.php
+++ b/ext/phar/package.php
@@ -43,6 +43,29 @@ 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.0RC2:
+ fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
+ getSignature() call
+ fixed PHP Bug #49020: phar misinterprets ustar long filename standard
+ fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
+ fixed PHP Bug #48791: open office files always reported as corrupted
+ fixed PHP Bug #48783: make install will fail saying phar file exists
+ fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
+ fixed PHP Bug #48681: openssl signature verification for tar archives broken
+ fixed PHP Bug #48377: error message unclear on converting phar with existing file
+ fixed isset() on sub-directories (isset("blah") if file "blah/foo.php" exists)
+
+ make phar work in PHP 6
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to \'PHP_SHA512Init\'
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
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
@@ -61,7 +84,7 @@ require_once 'PEAR/PackageFileManager2.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$options = array(
- 'filelistgenerator' => 'CVS',
+ 'filelistgenerator' => 'svn',
'changelogoldtonew' => false,
'simpleoutput' => true,
'baseinstalldir' => '/',
@@ -101,8 +124,8 @@ $package->setPackageType('extsrc');
$package->addRelease();
$package->setReleaseVersion(phpversion('phar'));
$package->setAPIVersion(Phar::apiVersion());
-$package->setReleaseStability('beta');
-$package->setAPIStability('beta');
+$package->setReleaseStability('stable');
+$package->setAPIStability('stable');
$package->setNotes("\n$notes\n");
//$package->addGlobalReplacement('package-info', '@package_version@', 'version');
$package->generateContents();
diff --git a/ext/phar/package.xml b/ext/phar/package.xml
index e4c2fe4f3..45bdb9edc 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.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">
+<package packagerversion="1.8.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,19 +42,18 @@ a 6x speedup measured running phpMyAdmin as a phar archive.</description>
<email>sfox@php.net</email>
<active>yes</active>
</developer>
- <date>2008-08-31</date>
- <time>15:34:02</time>
+ <date>2009-07-26</date>
+ <time>15:41:33</time>
<version>
- <release>2.0.0RC1</release>
+ <release>2.0.0</release>
<api>1.1.1</api>
</version>
<stability>
- <release>beta</release>
- <api>beta</api>
+ <release>stable</release>
+ <api>stable</api>
</stability>
<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(),
@@ -97,13 +96,35 @@ 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.0RC2:
+ fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
+ getSignature() call
+ fixed PHP Bug #49020: phar misinterprets ustar long filename standard
+ fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
+ fixed PHP Bug #48791: open office files always reported as corrupted
+ fixed PHP Bug #48783: make install will fail saying phar file exists
+ fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
+ fixed PHP Bug #48681: openssl signature verification for tar archives broken
+ fixed PHP Bug #48377: error message unclear on converting phar with existing file
+ fixed isset() on sub-directories (isset(&quot;blah&quot;) if file &quot;blah/foo.php&quot; exists)
+
+ make phar work in PHP 6
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
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>
<dir baseinstalldir="/" name="/">
@@ -119,6 +140,10 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<dir name="tests">
<dir name="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" />
<file name="frontcontroller2.phar" role="test" />
@@ -155,7 +180,95 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="frontcontroller18.phar.inc" role="test" />
<file name="frontcontroller19.phar" role="test" />
<file name="frontcontroller19.phar.inc" role="test" />
+ <file name="md5.phar" role="test" />
+ <file name="nophar.phar" role="test" />
+ <file name="nophar.phar.inc" 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" />
+ <file name="write.phar" role="test" />
+ <file name="write.phar.inc" role="test" />
+ <file name="write2.phar" role="test" />
+ <file name="write2.phar.inc" role="test" />
+ <file name="write3.phar" role="test" />
+ <file name="write3.phar.inc" role="test" />
+ <file name="write4.phar" role="test" />
+ <file name="write4.phar.inc" role="test" />
+ <file name="write5.phar" role="test" />
+ <file name="write5.phar.inc" role="test" />
+ <file name="write6.phar" role="test" />
+ <file name="write6.phar.inc" role="test" />
+ <file name="write7.phar" role="test" />
+ <file name="write7.phar.inc" role="test" />
+ <file name="write8.phar" role="test" />
+ <file name="write8.phar.inc" role="test" />
+ <file name="write9.phar" role="test" />
+ <file name="write9.phar.inc" role="test" />
+ <file name="write10.phar" role="test" />
+ <file name="write10.phar.inc" role="test" />
+ <file name="write11.phar" role="test" />
+ <file name="write11.phar.inc" role="test" />
+ <file name="write12.phar" role="test" />
+ <file name="write12.phar.inc" role="test" />
+ <file name="write13.phar" role="test" />
+ <file name="write13.phar.inc" role="test" />
+ <file name="write14.phar" role="test" />
+ <file name="write14.phar.inc" role="test" />
+ <file name="write15.phar" role="test" />
+ <file name="write15.phar.inc" role="test" />
+ <file name="write16.phar" role="test" />
+ <file name="write16.phar.inc" role="test" />
+ <file name="write17.phar" role="test" />
+ <file name="write17.phar.inc" role="test" />
+ <file name="write18.phar" role="test" />
+ <file name="write18.phar.inc" role="test" />
+ <file name="write19.phar" role="test" />
+ <file name="write19.phar.inc" role="test" />
+ <file name="write20.phar" role="test" />
+ <file name="write20.phar.inc" role="test" />
+ <file name="write21.phar" role="test" />
+ <file name="write21.phar.inc" role="test" />
+ <file name="write22.phar" role="test" />
+ <file name="write22.phar.inc" role="test" />
+ <file name="write23.phar" role="test" />
+ <file name="write23.phar.inc" role="test" />
+ <file name="write24.phar" role="test" />
+ <file name="write24.phar.inc" role="test" />
+ <file name="write25.phar" role="test" />
+ <file name="write25.phar.inc" role="test" />
+ <file name="zfapp.tgz" role="test" />
</dir> <!-- /tests/cache_list/files -->
+ <file name="copyonwrite1.phar.phpt" role="test" />
+ <file name="copyonwrite2.phar.phpt" role="test" />
+ <file name="copyonwrite3.phar.phpt" role="test" />
+ <file name="copyonwrite4.phar.phpt" role="test" />
+ <file name="copyonwrite4a.phpt" role="test" />
+ <file name="copyonwrite5.phar.phpt" role="test" />
+ <file name="copyonwrite6.phar.phpt" role="test" />
+ <file name="copyonwrite7.phar.phpt" role="test" />
+ <file name="copyonwrite8.phar.phpt" role="test" />
+ <file name="copyonwrite9.phar.phpt" role="test" />
+ <file name="copyonwrite10.phar.phpt" role="test" />
+ <file name="copyonwrite11.phar.phpt" role="test" />
+ <file name="copyonwrite12.phar.phpt" role="test" />
+ <file name="copyonwrite13.phar.phpt" role="test" />
+ <file name="copyonwrite14.phar.phpt" role="test" />
+ <file name="copyonwrite15.phar.phpt" role="test" />
+ <file name="copyonwrite16.phar.phpt" role="test" />
+ <file name="copyonwrite17.phar.phpt" role="test" />
+ <file name="copyonwrite18.phar.phpt" role="test" />
+ <file name="copyonwrite19.phar.phpt" role="test" />
+ <file name="copyonwrite20.phar.phpt" role="test" />
+ <file name="copyonwrite21.phar.phpt" role="test" />
+ <file name="copyonwrite22.phar.phpt" role="test" />
+ <file name="copyonwrite23.phar.phpt" role="test" />
+ <file name="copyonwrite24.phar.phpt" role="test" />
+ <file name="copyonwrite25.phar.phpt" role="test" />
<file name="frontcontroller1.phpt" role="test" />
<file name="frontcontroller2.phpt" role="test" />
<file name="frontcontroller3.phpt" role="test" />
@@ -232,6 +345,9 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="frontcontroller18.phar.inc" role="test" />
<file name="frontcontroller19.phar" role="test" />
<file name="frontcontroller19.phar.inc" role="test" />
+ <file name="include_path.phar" role="test" />
+ <file name="include_path.phar.inc" role="test" />
+ <file name="include_path2.phar" role="test" />
<file name="md5.phar" role="test" />
<file name="nophar.phar" role="test" />
<file name="nophar.phar.inc" role="test" />
@@ -279,8 +395,13 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="frontcontroller11.phar.tar" role="test" />
<file name="frontcontroller12.phar.inc" role="test" />
<file name="frontcontroller12.phar.tar" role="test" />
+ <file name="links.phar.tar" role="test" />
<file name="links.tar" role="test" />
+ <file name="make.dangerous.tar.php.inc" role="test" />
<file name="make_invalid_tar.php.inc" role="test" />
+ <file name="Net_URL-1.0.15.tgz" role="test" />
+ <file name="P1-1.0.0.tgz" role="test" />
+ <file name="P1-1.0.0.tgz.pubkey" role="test" />
<file name="subdirlink.tar" role="test" />
<file name="tarmaker.php.inc" role="test" />
<file name="tinylink.tar" role="test" />
@@ -294,6 +415,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="badalias.phpt" role="test" />
<file name="badchecksum.phpt" role="test" />
<file name="bignames.phpt" role="test" />
+ <file name="bignames_overflow.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" />
@@ -328,6 +450,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="links3.phpt" role="test" />
<file name="links4.phpt" role="test" />
<file name="links5.phpt" role="test" />
+ <file name="links6.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" />
@@ -350,6 +473,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="phar_convert_phar.phpt" role="test" />
<file name="phar_convert_phar2.phpt" role="test" />
<file name="phar_convert_phar3.phpt" role="test" />
+ <file name="phar_convert_phar4.phpt" role="test" />
<file name="phar_copy.phpt" role="test" />
<file name="phar_magic.phpt" role="test" />
<file name="phar_setalias.phpt" role="test" />
@@ -375,7 +499,9 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="tar_gzipU.phpt" role="test" />
<file name="tar_makebz2.phpt" role="test" />
<file name="tar_makegz.phpt" role="test" />
+ <file name="tar_nohash.phpt" role="test" />
<file name="tar_nostub.phpt" role="test" />
+ <file name="tar_openssl_hash.phpt" role="test" />
<file name="truncated.phpt" role="test" />
</dir> <!-- /tests/tar -->
<dir name="zip">
@@ -385,6 +511,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="badalias3.phar.zip" role="test" />
<file name="badalias4.phar.zip" role="test" />
<file name="badalias5.phar.zip" role="test" />
+ <file name="bz2_alias.phar.zip" role="test" />
<file name="bzip2.zip" role="test" />
<file name="cdir_offset.zip" role="test" />
<file name="compress_unsup1.zip" role="test" />
@@ -442,9 +569,11 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="nozipend.zip" role="test" />
<file name="odt.odt" role="test" />
<file name="stdin.zip" role="test" />
+ <file name="test.odt" role="test" />
<file name="truncfilename.zip" role="test" />
<file name="zip.zip" role="test" />
<file name="zipmaker.php.inc" role="test" />
+ <file name="zlib_alias.phar.zip" role="test" />
</dir> <!-- /tests/zip/files -->
<file name="033.phpt" role="test" />
<file name="033a.phpt" role="test" />
@@ -452,6 +581,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="all.phpt" role="test" />
<file name="allU.phpt" role="test" />
<file name="badalias.phpt" role="test" />
+ <file name="bug48791.phpt" role="test" />
<file name="bzip2.phpt" role="test" />
<file name="corrupt_001.phpt" role="test" />
<file name="corrupt_002.phpt" role="test" />
@@ -526,6 +656,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<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" />
@@ -534,6 +665,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="rename_dir.phpt" role="test" />
<file name="rmdir.phpt" role="test" />
<file name="unixzip.phpt" role="test" />
+ <file name="zlib.phpt" role="test" />
</dir> <!-- /tests/zip -->
<file name="001.phpt" role="test" />
<file name="002.phpt" role="test" />
@@ -586,6 +718,12 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="bug13786.phpt" role="test" />
<file name="bug45218_SLOWTEST.phpt" role="test" />
<file name="bug45218_SLOWTESTU.phpt" role="test" />
+ <file name="bug46032.phpt" role="test" />
+ <file name="bug46060.phpt" role="test" />
+ <file name="bug46178.phpt" role="test" />
+ <file name="bug47085.phpt" role="test" />
+ <file name="bug48377.2.phpt" role="test" />
+ <file name="bug48377.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" />
@@ -604,6 +742,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="fopen5.2.phpt" role="test" />
<file name="fopen_edgecases.phpt" role="test" />
<file name="fopen_edgecases2.phpt" role="test" />
+ <file name="fopen_edgecases2U.phpt" role="test" />
<file name="front.phar.phpt" role="test" />
<file name="frontcontroller1.phpt" role="test" />
<file name="frontcontroller2.phpt" role="test" />
@@ -640,8 +779,8 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="frontcontroller33.phpt" role="test" />
<file name="frontcontroller34.phpt" role="test" />
<file name="include_path.phpt" role="test" />
+ <file name="include_path_advanced.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" />
@@ -693,10 +832,9 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<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_construct_invalidurl.phpt" role="test" />
<file name="phar_convert_again.phpt" role="test" />
<file name="phar_convert_repeated.phpt" role="test" />
<file name="phar_convert_repeated_b.phpt" role="test" />
@@ -783,6 +921,7 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="phpinfo_004.phpt" role="test" />
<file name="readfile.phpt" role="test" />
<file name="readfile_edgecases.phpt" role="test" />
+ <file name="readfile_edgecasesU.phpt" role="test" />
<file name="refcount1.phpt" role="test" />
<file name="refcount1_5_2.phpt" role="test" />
<file name="rename.phpt" role="test" />
@@ -815,7 +954,6 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<file name="Makefile.frag" role="src" />
<file name="makestub.php" role="php" />
<file name="phar.c" role="src" />
- <file name="phar.phar" role="script" />
<file name="pharzip.h" role="src" />
<file name="phar_internal.h" role="src" />
<file name="phar_object.c" role="src" />
@@ -866,17 +1004,101 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
<changelog>
<release>
<version>
- <release>2.0.0RC1</release>
+ <release>2.0.0</release>
<api>1.1.1</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
- <date>2008-08-31</date>
+ <date>2009-07-26</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
+ * 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]
+ * 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.0RC2:
+ fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
+ getSignature() call
+ fixed PHP Bug #49020: phar misinterprets ustar long filename standard
+ fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
+ fixed PHP Bug #48791: open office files always reported as corrupted
+ fixed PHP Bug #48783: make install will fail saying phar file exists
+ fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
+ fixed PHP Bug #48681: openssl signature verification for tar archives broken
+ fixed PHP Bug #48377: error message unclear on converting phar with existing file
+ fixed isset() on sub-directories (isset(&quot;blah&quot;) if file &quot;blah/foo.php&quot; exists)
+
+ make phar work in PHP 6
+Changes since 2.0.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
+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.0RC2</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2009-06-04</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(),
@@ -919,13 +1141,84 @@ 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.0RC1:
+ security vulnerability in handling of long tar filenames fixed
+ fixed PECL Bug #14646: phar error message unclear with php stream wrappers
+ fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
+ fixed PHP Bug #48257: PharData throws an exception with non-phar tar
+ fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
+ fixed PHP Bug #46032: PharData::__construct() - wrong memory read
+ fixed PHP Bug #46060: Phar::addEmptyDir() breaks
+ fixed PHP Bug #45907: undefined reference to &apos;PHP_SHA512Init&apos;
+ fixed PHP Bug #45726: PHP_Archive / Archive.php missing
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.0RC1</release>
+ <api>1.1.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2008-08-31</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
+ * 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]
+ * 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
+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>
@@ -939,7 +1232,8 @@ Changes since 2.0.0b1: addition of phar.cache_list, many performance improvement
</stability>
<date>2008-05-12</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>BC BREAKING RELEASE
+ <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().
@@ -978,7 +1272,8 @@ Security addition
* 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>
+ conversion API refactored
+ </notes>
</release>
<release>
<version>
@@ -991,7 +1286,8 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
</stability>
<date>2008-03-27</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>Major feature functionality release
+ <notes>
+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::isTar(), Phar::isZip(), and Phar::isPhar() [Greg]
@@ -1014,7 +1310,8 @@ Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression
* implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
* add Phar::delete() [Greg]
-Changes since 2.0.0a1: fix build in PHP 5.2</notes>
+Changes since 2.0.0a1: fix build in PHP 5.2
+ </notes>
</release>
<release>
<version>
@@ -1027,7 +1324,8 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2008-03-26</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>Major feature functionality release
+ <notes>
+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::isTar(), Phar::isZip(), and Phar::isPhar() [Greg]
@@ -1048,7 +1346,8 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
* implement Phar::copy(string $from, string $to) [Greg]
* implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
* implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
- * add Phar::delete() [Greg]</notes>
+ * add Phar::delete() [Greg]
+ </notes>
</release>
<release>
<version>
@@ -1061,7 +1360,8 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2007-08-24</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>* add Phar::setAlias() [Greg]
+ <notes>
+* add Phar::setAlias() [Greg]
* fix too many open file handles issue [Greg]
* fix rename [Greg]
* add Phar::getAlias() [Marcus]
@@ -1072,7 +1372,8 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
* Made Phar::loadPhar() and Phar::mapPhar() ignore extracted archives [Marcus]
* Fix issue with compressed entries and uncompressing entries [Marcus]
* Verify stubs before writing [Marcus]
-* Always use longest stub end to avoid issues with length field [Marcus]</notes>
+* Always use longest stub end to avoid issues with length field [Marcus]
+ </notes>
</release>
<release>
<version>
@@ -1085,13 +1386,15 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2007-05-18</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>* add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
+ <notes>
+* add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
* add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
* fix Phar::CanWrite() [Marcus]
* add preliminary phar command (phar.php) [Marcus]
* add phar command (phar.phar) [Marcus]
* list all available compression methods using Phar::getSupportedCompression() [Marcus]
-* remove RINIT [Marcus]</notes>
+* remove RINIT [Marcus]
+ </notes>
</release>
<release>
<version>
@@ -1104,13 +1407,15 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2007-04-12</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>* implement ability connect a phar file &apos;phar://whatever&apos; to a directory. That way all
+ <notes>
+* implement ability connect a phar file &apos;phar://whatever&apos; to a directory. That way all
access to that phar archive are directed to the extracted directory. This
allows to have the installed files and the archive keep the same includes.
[Marcus]
* implement SHA-2 (256, 512) support [Marcus]
* implement setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512 Phar::PGP to
- choose the kind of signature to use (PGP falls back to SHA1) [Greg]</notes>
+ choose the kind of signature to use (PGP falls back to SHA1) [Greg]
+ </notes>
</release>
<release>
<version>
@@ -1123,7 +1428,9 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2007-03-28</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>* Fix return value of unlink() and rename() when used for phar archievs. [Marcus]</notes>
+ <notes>
+* Fix return value of unlink() and rename() when used for phar archievs. [Marcus]
+ </notes>
</release>
<release>
<version>
@@ -1136,9 +1443,11 @@ Changes since 2.0.0a1: fix build in PHP 5.2</notes>
</stability>
<date>2007-03-26</date>
<license uri="http://www.php.net/license">PHP License</license>
- <notes>*BACKWARDS COMPATIBILITY BREAK*
+ <notes>
+*BACKWARDS COMPATIBILITY BREAK*
Rename Phar-&gt;begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering
-Note that isBuffering() returns the opposite value to isFlushingToPhar()</notes>
+Note that isBuffering() returns the opposite value to isFlushingToPhar()
+ </notes>
</release>
</changelog>
</package>
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index e41233596..571ae4577 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.62 2009/05/13 20:25:43 cellog Exp $ */
+/* $Id: phar.c 286338 2009-07-26 01:03:47Z cellog $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1972,11 +1972,13 @@ woohoo:
if (keylen > (uint) filename_len) {
zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
+ PHAR_STR_FREE(str_key);
continue;
}
if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
|| filename[keylen] == '/' || filename[keylen] == '\0')) {
+ PHAR_STR_FREE(str_key);
if (FAILURE == zend_hash_get_current_data(&(PHAR_GLOBALS->phar_fname_map), (void **) &pphar)) {
break;
}
@@ -1984,6 +1986,7 @@ woohoo:
goto woohoo;
}
+ PHAR_STR_FREE(str_key);
zend_hash_move_forward(&(PHAR_GLOBALS->phar_fname_map));
}
@@ -1999,17 +2002,20 @@ woohoo:
if (keylen > (uint) filename_len) {
zend_hash_move_forward(&cached_phars);
+ PHAR_STR_FREE(str_key);
continue;
}
if (!memcmp(filename, str_key, keylen) && ((uint)filename_len == keylen
|| filename[keylen] == '/' || filename[keylen] == '\0')) {
+ PHAR_STR_FREE(str_key);
if (FAILURE == zend_hash_get_current_data(&cached_phars, (void **) &pphar)) {
break;
}
*ext_str = filename + (keylen - (*pphar)->ext_len);
goto woohoo;
}
+ PHAR_STR_FREE(str_key);
zend_hash_move_forward(&cached_phars);
}
}
@@ -2407,6 +2413,7 @@ int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error
if (entry->is_zip && process_zip > 0) {
/* verify local file header */
phar_zip_file_header local;
+ phar_zip_data_desc desc;
if (SUCCESS != phar_open_archive_fp(idata->phar TSRMLS_CC)) {
spprintf(error, 0, "phar error: unable to open zip-based phar archive \"%s\" to verify local file header for file \"%s\"", idata->phar->fname, entry->filename);
@@ -2420,6 +2427,25 @@ int phar_postprocess_file(phar_entry_data *idata, php_uint32 crc32, char **error
return FAILURE;
}
+ /* check for data descriptor */
+ if (((PHAR_ZIP_16(local.flags)) & 0x8) == 0x8) {
+ php_stream_seek(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ entry->header_offset + sizeof(local) +
+ PHAR_ZIP_16(local.filename_len) +
+ PHAR_ZIP_16(local.extra_len) +
+ entry->compressed_filesize, SEEK_SET);
+ if (sizeof(desc) != php_stream_read(phar_get_entrypfp(idata->internal_file TSRMLS_CC),
+ (char *) &desc, sizeof(desc))) {
+ spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local data descriptor for file \"%s\")", idata->phar->fname, entry->filename);
+ return FAILURE;
+ }
+ if (desc.signature[0] == 'P' && desc.signature[1] == 'K') {
+ memcpy(&(local.crc32), &(desc.crc32), 12);
+ } else {
+ /* old data descriptors have no signature */
+ memcpy(&(local.crc32), &desc, 12);
+ }
+ }
/* verify local header */
if (entry->filename_len != PHAR_ZIP_16(local.filename_len) || entry->crc32 != PHAR_ZIP_32(local.crc32) || entry->uncompressed_filesize != PHAR_ZIP_32(local.uncompsize) || entry->compressed_filesize != PHAR_ZIP_32(local.compsize)) {
spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (local header of file \"%s\" does not match central directory)", idata->phar->fname, entry->filename);
@@ -2621,7 +2647,11 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
len = -len;
}
user_stub = 0;
+#if PHP_MAJOR_VERSION >= 6
+ if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
+#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+#endif
if (closeoldfile) {
php_stream_close(oldfile);
}
@@ -3635,7 +3665,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.62 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 286338 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
diff --git a/ext/phar/phar/directorygraphiterator.inc b/ext/phar/phar/directorygraphiterator.inc
index 846680053..5a658ddab 100755
--- a/ext/phar/phar/directorygraphiterator.inc
+++ b/ext/phar/phar/directorygraphiterator.inc
@@ -1,34 +1,34 @@
-<?php
-
-/** @file directorygraphiterator.inc
- * @ingroup Examples
- * @brief class DirectoryGraphIterator
- * @author Marcus Boerger
- * @date 2003 - 2008
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A tree iterator that only shows directories.
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryGraphIterator extends DirectoryTreeIterator
-{
- function __construct($path)
- {
- RecursiveIteratorIterator::__construct(
- new RecursiveCachingIterator(
- new ParentIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- )
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-}
-
+<?php
+
+/** @file directorygraphiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryGraphIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2008
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A tree iterator that only shows directories.
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryGraphIterator extends DirectoryTreeIterator
+{
+ function __construct($path)
+ {
+ RecursiveIteratorIterator::__construct(
+ new RecursiveCachingIterator(
+ new ParentIterator(
+ new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
+ )
+ ),
+ CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
+ ),
+ parent::SELF_FIRST
+ );
+ }
+}
+
?> \ No newline at end of file
diff --git a/ext/phar/phar/directorytreeiterator.inc b/ext/phar/phar/directorytreeiterator.inc
index 2c71c93dc..9ed2e1a1b 100755
--- a/ext/phar/phar/directorytreeiterator.inc
+++ b/ext/phar/phar/directorytreeiterator.inc
@@ -1,54 +1,54 @@
-<?php
-
-/** @file directorytreeiterator.inc
- * @ingroup Examples
- * @brief class DirectoryTreeIterator
- * @author Marcus Boerger
- * @date 2003 - 2008
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief DirectoryIterator to generate ASCII graphic directory trees
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryTreeIterator extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(
- new RecursiveCachingIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-
- /** @return the current element prefixed with ASCII graphics
- */
- function current()
- {
- $tree = '';
- for ($l=0; $l < $this->getDepth(); $l++) {
- $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
- }
- return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
- . $this->getSubIterator($l)->__toString();
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
+<?php
+
+/** @file directorytreeiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryTreeIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2008
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief DirectoryIterator to generate ASCII graphic directory trees
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryTreeIterator extends RecursiveIteratorIterator
+{
+ /** Construct from a path.
+ * @param $path directory to iterate
+ */
+ function __construct($path)
+ {
+ parent::__construct(
+ new RecursiveCachingIterator(
+ new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
+ ),
+ CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
+ ),
+ parent::SELF_FIRST
+ );
+ }
+
+ /** @return the current element prefixed with ASCII graphics
+ */
+ function current()
+ {
+ $tree = '';
+ for ($l=0; $l < $this->getDepth(); $l++) {
+ $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
+ }
+ return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
+ . $this->getSubIterator($l)->__toString();
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getSubIterator(), $func), $params);
+ }
+}
+
?> \ No newline at end of file
diff --git a/ext/phar/phar/invertedregexiterator.inc b/ext/phar/phar/invertedregexiterator.inc
index de21b01e0..aec87e6ab 100755
--- a/ext/phar/phar/invertedregexiterator.inc
+++ b/ext/phar/phar/invertedregexiterator.inc
@@ -1,27 +1,27 @@
-<?php
-
-/** @file invertedregexiterator.inc
- * @ingroup Phar
- * @brief class InvertedRegexIterator
- * @author Marcus Boerger
- * @date 2007 - 2008
- *
- * Inverted RegexIterator
- */
-
-/** @ingroup Phar
- * @brief Inverted RegexIterator
- * @author Marcus Boerger
- * @version 1.0
- */
-class InvertedRegexIterator extends RegexIterator
-{
- /** @return !RegexIterator::accept()
- */
- function accept()
- {
- return !RegexIterator::accept();
- }
-}
-
+<?php
+
+/** @file invertedregexiterator.inc
+ * @ingroup Phar
+ * @brief class InvertedRegexIterator
+ * @author Marcus Boerger
+ * @date 2007 - 2008
+ *
+ * Inverted RegexIterator
+ */
+
+/** @ingroup Phar
+ * @brief Inverted RegexIterator
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class InvertedRegexIterator extends RegexIterator
+{
+ /** @return !RegexIterator::accept()
+ */
+ function accept()
+ {
+ return !RegexIterator::accept();
+ }
+}
+
?> \ No newline at end of file
diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc
index 6b70cef1b..9886676cc 100755
--- a/ext/phar/phar/pharcommand.inc
+++ b/ext/phar/phar/pharcommand.inc
@@ -1566,7 +1566,7 @@ class PharCommand extends CLICommand
$use_ext = extension_loaded('phar');
$version = array(
'PHP Version' => phpversion(),
- 'phar.phar version' => '$Revision: 1.49.2.16 $',
+ 'phar.phar version' => '$Revision: 282735 $',
'Phar EXT version' => $use_ext ? phpversion('phar') : 'Not available',
'Phar API version' => Phar::apiVersion(),
'Phar-based phar archives' => true,
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index 445784fea..da9cf22ad 100755
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.109.2.31 2009/05/13 20:25:43 cellog Exp $ */
+/* $Id: phar_internal.h 286338 2009-07-26 01:03:47Z cellog $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -544,12 +544,47 @@ typedef zstr phar_zstr;
spprintf(&b, 0, "%s", a.s);
#define PHAR_ZSTR(a, b) \
b = ZSTR(a);
+#define PHAR_STR_FREE(a) \
+ efree(a);
+static inline int phar_make_unicode(zstr *c_var, char *arKey, uint nKeyLength TSRMLS_DC)
+{
+ int c_var_len;
+ UConverter *conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv));
+
+ c_var->u = NULL;
+ if (zend_string_to_unicode(conv, &c_var->u, &c_var_len, arKey, nKeyLength TSRMLS_CC) == FAILURE) {
+
+ if (c_var->u) {
+ efree(c_var->u);
+ }
+ return 0;
+
+ }
+ return c_var_len;
+}
+static inline int phar_find_key(HashTable *_SERVER, char *key, int len, void **stuff TSRMLS_DC)
+{
+ if (SUCCESS == zend_hash_find(_SERVER, key, len, stuff)) {
+ return 1;
+ } else {
+ int s = len;
+ zstr var;
+ s = phar_make_unicode(&var, key, len TSRMLS_CC);
+ if (SUCCESS == zend_u_hash_find(_SERVER, IS_UNICODE, var, s, stuff)) {
+ efree(var.u);
+ return 1;
+ }
+ efree(var.u);
+ return 0;
+ }
+}
#else
typedef char *phar_zstr;
#define PHAR_STR(a, b) \
b = a;
#define PHAR_ZSTR(a, b) \
b = a;
+#define PHAR_STR_FREE(a)
#endif
BEGIN_EXTERN_C()
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 76016e706..69e8e382b 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.266.2.63 2009/06/05 04:46:49 cellog Exp $ */
+/* $Id: phar_object.c 286518 2009-07-29 16:17:57Z felipe $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -30,6 +30,12 @@ static zend_class_entry *phar_ce_PharException;
static zend_class_entry *phar_ce_entry;
#endif
+#if PHP_MAJOR_VERSION > 5 || ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3))
+# define PHAR_ARG_INFO
+#else
+# define PHAR_ARG_INFO static
+#endif
+
static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_DC) /* {{{ */
{
char *ext;
@@ -52,10 +58,15 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_
static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */
{
+#if PHP_MAJOR_VERSION >= 6
+ int is_unicode = 0;
+#endif
HashTable *_SERVER;
zval **stuff;
char *path_info;
int basename_len = strlen(basename);
+ int code;
+ zval *temp;
/* "tweak" $_SERVER variables requested in earlier call to Phar::mungServer() */
if (!PG(http_globals)[TRACK_VARS_SERVER]) {
@@ -65,9 +76,17 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
_SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -77,13 +96,26 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
- zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), (void *) &temp, sizeof(zval **), NULL);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
+ zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL);
}
}
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -91,6 +123,11 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL);
}
@@ -99,9 +136,17 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -111,15 +156,28 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -129,15 +187,28 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -145,14 +216,27 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff TSRMLS_CC)) {
+ if (Z_TYPE_PP(stuff) == IS_UNICODE) {
+ is_unicode = 1;
+ zval_unicode_to_string(*stuff TSRMLS_CC);
+ } else {
+ is_unicode = 0;
+ }
+#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) {
- int code;
- zval *temp;
+#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@@ -160,6 +244,11 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
+#if PHP_MAJOR_VERSION >= 6
+ if (is_unicode) {
+ zval_string_to_unicode(*stuff TSRMLS_CC);
+ }
+#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
@@ -851,7 +940,11 @@ PHP_METHOD(Phar, webPhar)
if (ext) {
++ext;
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val TSRMLS_CC)) {
+#else
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) {
+#endif
switch (Z_TYPE_PP(val)) {
case IS_LONG:
if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) {
@@ -865,6 +958,11 @@ PHP_METHOD(Phar, webPhar)
RETURN_FALSE;
}
break;
+#if PHP_MAJOR_VERSION >= 6
+ case IS_UNICODE:
+ zval_unicode_to_string(*(val) TSRMLS_CC);
+ /* break intentionally omitted */
+#endif
case IS_STRING:
mime_type = Z_STRVAL_PP(val);
code = PHAR_MIME_OTHER;
@@ -915,12 +1013,26 @@ PHP_METHOD(Phar, mungServer)
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) {
zval **data = NULL;
+#if PHP_MAJOR_VERSION >= 6
+ zval *unicopy = NULL;
+#endif
if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()");
return;
}
+#if PHP_MAJOR_VERSION >= 6
+ if (Z_TYPE_PP(data) == IS_UNICODE) {
+ MAKE_STD_ZVAL(unicopy);
+ *unicopy = **data;
+ zval_copy_ctor(unicopy);
+ INIT_PZVAL(unicopy);
+ zval_unicode_to_string(unicopy TSRMLS_CC);
+ data = &unicopy;
+ }
+#endif
+
if (Z_TYPE_PP(data) != IS_STRING) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
@@ -942,6 +1054,11 @@ PHP_METHOD(Phar, mungServer)
if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
}
+#if PHP_MAJOR_VERSION >= 6
+ if (unicopy) {
+ zval_ptr_dtor(&unicopy);
+ }
+#endif
}
}
/* }}} */
@@ -1476,6 +1593,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
spprintf(&str_key, 0, "%s", key);
#else
spprintf(&str_key, 0, "%v", key);
+ ezfree(key);
#endif
} else {
PHAR_STR(key, str_key);
@@ -1537,7 +1655,21 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
case SPL_FS_INFO:
case SPL_FS_FILE:
#if PHP_VERSION_ID >= 60000
- fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC);
+ if (intern->file_name_type == IS_UNICODE) {
+ zval zv;
+
+ INIT_ZVAL(zv);
+ Z_UNIVAL(zv) = intern->file_name;
+ Z_UNILEN(zv) = intern->file_name_len;
+ Z_TYPE(zv) = IS_UNICODE;
+
+ zval_copy_ctor(&zv);
+ zval_unicode_to_string(&zv TSRMLS_CC);
+ fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC);
+ ezfree(Z_UNIVAL(zv));
+ } else {
+ fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC);
+ }
#else
fname = expand_filepath(intern->file_name, NULL TSRMLS_CC);
#endif
@@ -1608,6 +1740,7 @@ phar_spl_fileinfo:
spprintf(&str_key, 0, "%s", key);
#else
spprintf(&str_key, 0, "%v", key);
+ ezfree(key);
#endif
} else {
PHAR_STR(key, str_key);
@@ -2037,6 +2170,7 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
int ext_len = ext ? strlen(ext) : 0;
int oldname_len;
phar_archive_data **pphar = NULL;
+ php_stream_statbuf ssb;
if (!ext) {
if (phar->is_zip) {
@@ -2107,6 +2241,8 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
spprintf(&newname, 0, "%s.%s", strtok(basename, "."), ext);
efree(basename);
+
+
basepath = estrndup(oldpath, (strlen(oldpath) - oldname_len));
phar->fname_len = spprintf(&newpath, 0, "%s%s", basepath, newname);
phar->fname = newpath;
@@ -2142,6 +2278,11 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
return NULL;
}
its_ok:
+ if (SUCCESS == php_stream_stat_path(newpath, &ssb)) {
+ efree(oldpath);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "phar \"%s\" exists and must be unlinked prior to conversion", newpath);
+ return NULL;
+ }
if (!phar->is_data) {
if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &(phar->ext_len), 1, 1, 1 TSRMLS_CC)) {
efree(oldpath);
@@ -3004,12 +3145,6 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
return;
}
- if (phar_obj->arc.archive->is_zip) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot set signature algorithm, not possible with zip-based phar archives");
- return;
- }
-
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &algo, &key, &key_len) != SUCCESS) {
return;
}
@@ -4766,7 +4901,11 @@ PHP_METHOD(PharFileInfo, getContent)
phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC);
Z_TYPE_P(return_value) = IS_STRING;
+#if PHP_MAJOR_VERSION >= 6
+ Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
+#else
Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
+#endif
if (!Z_STRVAL_P(return_value)) {
Z_STRVAL_P(return_value) = estrndup("", 0);
@@ -4978,7 +5117,7 @@ PHP_METHOD(PharFileInfo, decompress)
#endif /* HAVE_SPL */
/* {{{ phar methods */
-
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, flags)
@@ -4986,30 +5125,36 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
ZEND_ARG_INFO(0, fileformat)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mungServer, 0, 0, 1)
ZEND_ARG_INFO(0, munglist)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0)
ZEND_ARG_INFO(0, alias)
ZEND_ARG_INFO(0, index)
@@ -5018,105 +5163,126 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_webPhar, 0, 0, 0)
ZEND_ARG_INFO(0, rewrites)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_running, 0, 0, 1)
ZEND_ARG_INFO(0, retphar)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_ua, 0, 0, 1)
ZEND_ARG_INFO(0, archive)
ZEND_END_ARG_INFO()
#if HAVE_SPL
-
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_decomp, 0, 0, 0)
ZEND_ARG_INFO(0, file_ext)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_comp, 0, 0, 1)
ZEND_ARG_INFO(0, compression_type)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_compo, 0, 0, 0)
ZEND_ARG_INFO(0, compression_type)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_delete, 0, 0, 1)
ZEND_ARG_INFO(0, entry)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetExists, 0, 0, 1)
ZEND_ARG_INFO(0, entry)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setAlias, 0, 0, 1)
ZEND_ARG_INFO(0, alias)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_setMetadata, 0, 0, 1)
ZEND_ARG_INFO(0, metadata)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_emptydir, 0, 0, 0)
ZEND_ARG_INFO(0, dirname)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
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()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_isff, 0, 0, 1)
ZEND_ARG_INFO(0, fileformat)
ZEND_END_ARG_INFO()
@@ -5189,10 +5355,12 @@ zend_function_entry php_archive_methods[] = {
};
#if HAVE_SPL
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_END_ARG_INFO()
+PHAR_ARG_INFO
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry_chmod, 0, 0, 1)
ZEND_ARG_INFO(0, perms)
ZEND_END_ARG_INFO()
diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c
index d812b7133..f41d5897c 100755
--- a/ext/phar/phar_path_check.c
+++ b/ext/phar/phar_path_check.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_path_check.c,v 1.9.2.2 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: phar_path_check.c 272370 2008-12-31 11:15:49Z sebastian $ */
#include "phar_internal.h"
diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re
index 6e402d202..db92987c7 100755
--- a/ext/phar/phar_path_check.re
+++ b/ext/phar/phar_path_check.re
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_path_check.re,v 1.8.2.2 2008/12/31 11:13:54 sebastian Exp $ */
+/* $Id: phar_path_check.re 272369 2008-12-31 11:13:54Z sebastian $ */
#include "phar_internal.h"
diff --git a/ext/phar/pharzip.h b/ext/phar/pharzip.h
index 8c8afe9f1..b97b42851 100644
--- a/ext/phar/pharzip.h
+++ b/ext/phar/pharzip.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pharzip.h,v 1.2.2.3 2009/02/20 05:06:37 cellog Exp $ */
+/* $Id: pharzip.h 284658 2009-07-23 16:30:27Z cellog $ */
typedef struct _phar_zip_file_header {
char signature[4]; /* local file header signature 4 bytes (0x04034b50) */
@@ -37,6 +37,7 @@ typedef struct _phar_zip_file_header {
/* unused in this release */
typedef struct _phar_zip_file_datadesc {
+ char signature[4]; /* signature (optional) 4 bytes */
char crc32[4]; /* crc-32 4 bytes */
char compsize[4]; /* compressed size 4 bytes */
char uncompsize[4]; /* uncompressed size 4 bytes */
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
index 1d2448759..494ef6717 100644
--- a/ext/phar/php_phar.h
+++ b/ext/phar/php_phar.h
@@ -17,12 +17,12 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_phar.h,v 1.16.2.3 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: php_phar.h 290601 2009-11-12 17:43:23Z johannes $ */
#ifndef PHP_PHAR_H
#define PHP_PHAR_H
-#define PHP_PHAR_VERSION "2.0.0-dev"
+#define PHP_PHAR_VERSION "2.0.1"
#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 bc38f5e75..a357ba0da 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -207,18 +207,30 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *pat
fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
php_url_free(resource);
efree(internal_file);
+#if PHP_MAJOR_VERSION >= 6
+ if (context && context->options && phar_find_key(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption TSRMLS_CC)) {
+#else
if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
+#endif
pharcontext = HASH_OF(*pzoption);
if (idata->internal_file->uncompressed_filesize == 0
&& idata->internal_file->compressed_filesize == 0
+#if PHP_MAJOR_VERSION >= 6
+ && phar_find_key(pharcontext, "compress", sizeof("compress"), (void**)&pzoption TSRMLS_CC)
+#else
&& zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
+#endif
&& Z_TYPE_PP(pzoption) == IS_LONG
&& (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
) {
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
idata->internal_file->flags |= Z_LVAL_PP(pzoption);
}
+#if PHP_MAJOR_VERSION >= 6
+ if (phar_find_key(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption TSRMLS_CC)) {
+#else
if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
+#endif
if (idata->internal_file->metadata) {
zval_ptr_dtor(&idata->internal_file->metadata);
idata->internal_file->metadata = NULL;
@@ -635,6 +647,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
PHAR_STR(key, str_key);
if ((int)keylen >= internal_file_len || strncmp(str_key, internal_file, keylen)) {
zend_hash_move_forward_ex(&phar->mounted_dirs, &pos);
+ PHAR_STR_FREE(str_key);
continue;
} else {
char *test;
@@ -642,8 +655,10 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
php_stream_statbuf ssbi;
if (SUCCESS != zend_hash_find(&phar->manifest, str_key, keylen, (void **) &entry)) {
+ PHAR_STR_FREE(str_key);
goto free_resource;
}
+ PHAR_STR_FREE(str_key);
if (!entry->tmp || !entry->is_mounted) {
goto free_resource;
}
@@ -939,6 +954,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
#endif
}
+ PHAR_STR_FREE(str_key);
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
@@ -965,6 +981,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
#endif
efree(new_str_key);
}
+ PHAR_STR_FREE(str_key);
}
for (zend_hash_internal_pointer_reset(&phar->mounted_dirs);
@@ -992,6 +1009,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
#endif
efree(new_str_key);
}
+ PHAR_STR_FREE(str_key);
}
}
diff --git a/ext/phar/stream.h b/ext/phar/stream.h
index 566e7eb62..4609ca686 100644
--- a/ext/phar/stream.h
+++ b/ext/phar/stream.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: stream.h,v 1.3.2.4 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: stream.h 272370 2008-12-31 11:15:49Z sebastian $ */
BEGIN_EXTERN_C()
diff --git a/ext/phar/stub.h b/ext/phar/stub.h
index 53ab000dd..843c82074 100644
--- a/ext/phar/stub.h
+++ b/ext/phar/stub.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: stub.h,v 1.13.2.3 2008/12/31 11:15:42 sebastian Exp $ */
+/* $Id: stub.h 272370 2008-12-31 11:15:49Z sebastian $ */
static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len TSRMLS_DC)
{
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 85c064990..53255b1d2 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -200,6 +200,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
tar_header *hdr;
php_uint32 sum1, sum2, size, old;
phar_archive_data *myphar, **actual;
+ int last_was_longlink = 0;
if (error) {
*error = NULL;
@@ -255,6 +256,8 @@ 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)) {
+ off_t curloc;
+
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);
@@ -264,6 +267,7 @@ bail:
phar_destroy_phar_data(myphar TSRMLS_CC);
return FAILURE;
}
+ curloc = php_stream_tell(fp);
read = php_stream_read(fp, buf, size);
if (read != size) {
if (error) {
@@ -280,7 +284,8 @@ bail:
#else
# define PHAR_GET_32(buffer) (php_uint32) *(buffer)
#endif
- if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, PHAR_GET_32(buf), buf + 8, PHAR_GET_32(buf + 4), fname, &myphar->signature, &myphar->sig_len, error TSRMLS_CC)) {
+ myphar->sig_flags = PHAR_GET_32(buf);
+ if (FAILURE == phar_verify_signature(fp, php_stream_tell(fp) - size - 512, myphar->sig_flags, buf + 8, size - 8, fname, &myphar->signature, &myphar->sig_len, error TSRMLS_CC)) {
if (error) {
char *save = *error;
spprintf(error, 4096, "phar error: tar-based phar \"%s\" signature cannot be verified: %s", fname, save);
@@ -288,11 +293,11 @@ bail:
}
goto bail;
}
+ php_stream_seek(fp, curloc + 512, SEEK_SET);
/* 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) {
/* this is not good enough - seek succeeds even on truncated tars */
- php_stream_seek(fp, size, SEEK_CUR);
+ php_stream_seek(fp, 512, SEEK_CUR);
if ((uint)php_stream_tell(fp) > totalsize) {
if (error) {
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
@@ -328,7 +333,52 @@ bail:
goto bail;
}
- if (!old && hdr->prefix[0] != 0) {
+ if (!last_was_longlink && hdr->typeflag == 'L') {
+ last_was_longlink = 1;
+ /* support the ././@LongLink system for storing long filenames */
+ entry.filename_len = entry.uncompressed_filesize;
+ entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent);
+
+ read = php_stream_read(fp, entry.filename, entry.filename_len);
+ if (read != entry.filename_len) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ entry.filename[entry.filename_len] = '\0';
+
+ /* skip blank stuff */
+ size = ((size+511)&~511) - size;
+
+ /* 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) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+
+ read = php_stream_read(fp, buf, sizeof(buf));
+
+ if (read != sizeof(buf)) {
+ efree(entry.filename);
+ if (error) {
+ spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
+ }
+ php_stream_close(fp);
+ phar_destroy_phar_data(myphar TSRMLS_CC);
+ return FAILURE;
+ }
+ continue;
+ } else if (!last_was_longlink && !old && hdr->prefix[0] != 0) {
char name[256];
int i, j;
@@ -338,8 +388,12 @@ bail:
break;
}
}
+ name[i++] = '/';
for (j = 0; j < 100; j++) {
name[i+j] = hdr->name[j];
+ if (name[i+j] == '\0') {
+ break;
+ }
}
entry.filename_len = i+j;
@@ -349,7 +403,7 @@ bail:
entry.filename_len--;
}
entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent);
- } else {
+ } else if (!last_was_longlink) {
int i;
/* calculate strlen, which can be no longer than 100 */
@@ -367,6 +421,7 @@ bail:
entry.filename_len--;
}
}
+ last_was_longlink = 0;
phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len TSRMLS_CC);
@@ -635,14 +690,25 @@ static int phar_tar_writeheaders(void *pDest, void *argument TSRMLS_DC) /* {{{ *
memset((char *) &header, 0, sizeof(header));
if (entry->filename_len > 100) {
- if (entry->filename_len > 255) {
+ char *boundary;
+ if (entry->filename_len > 256) {
if (fp->error) {
spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filename);
}
return ZEND_HASH_APPLY_STOP;
}
- memcpy(header.prefix, entry->filename+100, entry->filename_len - 100);
- memcpy(header.name, entry->filename, 100);
+ boundary = entry->filename + entry->filename_len - 101;
+ while (*boundary && *boundary != '/') {
+ ++boundary;
+ }
+ if (!*boundary || ((boundary - entry->filename) > 155)) {
+ if (fp->error) {
+ spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filename);
+ }
+ return ZEND_HASH_APPLY_STOP;
+ }
+ memcpy(header.prefix, entry->filename, boundary - entry->filename);
+ memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename));
} else {
memcpy(header.name, entry->filename, entry->filename_len);
}
@@ -909,7 +975,11 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
len = -len;
}
user_stub = 0;
+#if PHP_MAJOR_VERSION >= 6
+ if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
+#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname);
}
diff --git a/ext/phar/tests/009.phpt b/ext/phar/tests/009.phpt
index 8b1db2f09..61933b381 100644
--- a/ext/phar/tests/009.phpt
+++ b/ext/phar/tests/009.phpt
@@ -9,7 +9,7 @@ phar.require_hash=0
$file = b"<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>";
-$file .= pack('VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . str_repeat('A', 500);
+$file .= (binary) pack(b'VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . (binary) str_repeat((binary)'A', 500);
file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
try {
include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
diff --git a/ext/phar/tests/016.phpt b/ext/phar/tests/016.phpt
index 302d06d3c..3288e8eca 100644
--- a/ext/phar/tests/016.phpt
+++ b/ext/phar/tests/016.phpt
@@ -9,14 +9,14 @@ phar.require_hash=0
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
+$file = b"<?php __HALT_COMPILER(); ?>";
// file length is too short
$files = array();
// "hi" gzdeflated
-$files['a'] = array('cont'=>'a','comp'=> pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
+$files['a'] = array('cont'=>b'a','comp'=> (binary)pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
$files['b'] = $files['a'];
-$files['c'] = array('cont'=>'*');
+$files['c'] = array('cont'=>b'*');
$files['d'] = $files['a'];
include 'files/phar_test.inc';
diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt
index 2f0e34ecf..d4291e622 100644
--- a/ext/phar/tests/badparameters.phpt
+++ b/ext/phar/tests/badparameters.phpt
@@ -76,11 +76,6 @@ $a->setSignatureAlgorithm(Phar::MD5);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
-try {
-$c->setSignatureAlgorithm(Phar::MD5);
-} catch (Exception $e) {
-echo $e->getMessage() . "\n";
-}
$a->compress(array());
try {
$a->compress(1);
@@ -160,7 +155,6 @@ A Phar stub cannot be set in a plain tar archive
Warning: Phar::setDefaultStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
Cannot change stub: phar.readonly=1
Cannot set signature algorithm, phar is read-only
-Cannot set signature algorithm, not possible with zip-based phar archives
Warning: Phar::compress() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
Cannot compress phar archive, phar is read-only
diff --git a/ext/phar/tests/bug46032.phpt b/ext/phar/tests/bug46032.phpt
index 4ff1026b5..5a88d5b42 100644
--- a/ext/phar/tests/bug46032.phpt
+++ b/ext/phar/tests/bug46032.phpt
@@ -6,7 +6,7 @@ Phar: bug #46032: PharData::__construct wrong memory read
--FILE--
<?php
-$a = __DIR__ .'/mytest';
+$a = dirname(__FILE__) .'/mytest';
try {
new phar($a);
@@ -24,11 +24,11 @@ new phardata('0000000000000000000');
?>
===DONE===
--EXPECTF--
-string(%d) "%smytest"
-string(%d) "%smytest"
+%string|unicode%(%d) "%smytest"
+%string|unicode%(%d) "%smytest"
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Cannot create phar '0000000000000000000', file extension (or combination) not recognised' in %sbug46032.php:%d
Stack trace:
-#0 %s(%d): PharData->__construct('000000000000000...')
+#0 %sbug46032.php(%d): PharData->__construct('000000000000000...')
#1 {main}
thrown in %sbug46032.php on line %d
diff --git a/ext/phar/tests/bug48377.2.phpt b/ext/phar/tests/bug48377.2.phpt
new file mode 100644
index 000000000..be2a0e103
--- /dev/null
+++ b/ext/phar/tests/bug48377.2.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Phar: PHP bug #48377 "error message unclear on converting phar with existing file" test #2
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
+
+$phar = new PharData($fname);
+$phar['x'] = 'hi';
+try {
+ $phar->convertToData(Phar::ZIP, Phar::NONE, '.2.phar.zip');
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
+--EXPECTF--
+data phar "%sbug48377.2.phar.zip" has invalid extension 2.phar.zip
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/bug48377.phpt b/ext/phar/tests/bug48377.phpt
new file mode 100644
index 000000000..6282a1565
--- /dev/null
+++ b/ext/phar/tests/bug48377.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Phar: PHP bug #48377 "error message unclear on converting phar with existing file"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
+
+touch($fname2);
+
+$phar = new Phar($fname, 0, 'a.phar');
+$phar['x'] = 'hi';
+try {
+ $phar->convertToData(Phar::ZIP, Phar::NONE, 'zip');
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage(),"\n";
+}
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
+--EXPECTF--
+phar "%sbug48377.zip" exists and must be unlinked prior to conversion
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite17.phar.phpt b/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
index 6e1308851..158c049b1 100644
--- a/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
+++ b/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
@@ -10,5 +10,5 @@ phar.readonly=0
files/write17.phar
--EXPECTF--
NULL
-string(2) "hi"
+%string|unicode%(2) "hi"
ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite19.phar.phpt b/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
index 4870550c4..6e03554d9 100644
--- a/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
+++ b/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
@@ -10,5 +10,5 @@ phar.readonly=0
files/write19.phar
--EXPECTF--
string(2) "hi"
-string(3) "hi2"
+%string|unicode%(3) "hi2"
ok \ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite6.phar.phpt b/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
index 6d6d56187..661fef42c 100644
--- a/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
+++ b/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
@@ -7,6 +7,7 @@ phar.readonly=0
open_basedir=
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip PHP 5.3+ required"); ?>
--FILE_EXTERNAL--
files/write6.phar
--CLEAN--
diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar b/ext/phar/tests/cache_list/files/frontcontroller12.phar
index 9e4558761..1cf362928 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller12.phar
+++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
index ba17df37e..f1e4645e2 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
+++ b/ext/phar/tests/cache_list/files/frontcontroller12.phar.inc
@@ -3,13 +3,13 @@
$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"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
';
$a->setStub('<?php
Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar b/ext/phar/tests/cache_list/files/frontcontroller14.phar
index 78a42a999..ebc3e9b40 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller14.phar
+++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
index d0ebd9a45..23104a642 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
+++ b/ext/phar/tests/cache_list/files/frontcontroller14.phar.inc
@@ -2,8 +2,8 @@
@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"]);
+var_dump($_SERVER[b"PATH_INFO"]);
+var_dump($_SERVER[b"PATH_TRANSLATED"]);
';
$a->setStub('<?php
function s($a)
diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar b/ext/phar/tests/cache_list/files/frontcontroller3.phar
index afcf03af3..35a23eadf 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller3.phar
+++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
index 2759d9ee4..6f9126ff4 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
+++ b/ext/phar/tests/cache_list/files/frontcontroller3.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => "a.phps");
+ static $b = array(b"/hi" => "a.phps");
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar b/ext/phar/tests/cache_list/files/frontcontroller4.phar
index 4c9a92a19..835946181 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller4.phar
+++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
index 5c6a43f95..daf807e41 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
+++ b/ext/phar/tests/cache_list/files/frontcontroller4.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => false);
+ static $b = array(b"/hi" => false);
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar b/ext/phar/tests/cache_list/files/frontcontroller8.phar
index ec05ceafb..c9c0e409e 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller8.phar
+++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
index 1dfb654a0..8629f0890 100644
--- a/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
+++ b/ext/phar/tests/cache_list/files/frontcontroller8.phar.inc
@@ -2,7 +2,7 @@
@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['a1.phps'] = '<?php var_dump($_SERVER[b"REQUEST_URI"], $_SERVER[b"PATH_INFO"]);';
$a['a.jpg'] = 'hio2';
$a['a.php'] = '<?php function hio(){}';
$a['fronk.gronk'] = 'hio3';
diff --git a/ext/phar/tests/cache_list/files/write24.phar b/ext/phar/tests/cache_list/files/write24.phar
index d726ceef7..36972f366 100644
--- a/ext/phar/tests/cache_list/files/write24.phar
+++ b/ext/phar/tests/cache_list/files/write24.phar
Binary files differ
diff --git a/ext/phar/tests/cache_list/files/write24.phar.inc b/ext/phar/tests/cache_list/files/write24.phar.inc
index ac9673196..216f7c46d 100644
--- a/ext/phar/tests/cache_list/files/write24.phar.inc
+++ b/ext/phar/tests/cache_list/files/write24.phar.inc
@@ -8,7 +8,7 @@ $phar->setStub('<?php
$p = new Phar(__FILE__);
var_dump(isset($p["newname"]));
$fp = fopen("phar://" . __FILE__ . "/newname", "w");
-fwrite($fp, "hi");
+fwrite($fp, b"hi");
fclose($fp);
var_dump(isset($p["newname"]));
echo "ok\n";
diff --git a/ext/phar/tests/cache_list/frontcontroller21.phpt b/ext/phar/tests/cache_list/frontcontroller21.phpt
index 9ed315d19..829f2986e 100644
--- a/ext/phar/tests/cache_list/frontcontroller21.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller21.phpt
@@ -15,7 +15,7 @@ files/frontcontroller12.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(10) "/index.php"
+%unicode|string%(10) "/index.php"
string(10) "/index.php"
string(%d) "phar://%sfrontcontroller21.php/index.php"
string(18) "/index.php?test=hi"
diff --git a/ext/phar/tests/cache_list/frontcontroller22.phpt b/ext/phar/tests/cache_list/frontcontroller22.phpt
index 82a8389ad..2769b01f2 100644
--- a/ext/phar/tests/cache_list/frontcontroller22.phpt
+++ b/ext/phar/tests/cache_list/frontcontroller22.phpt
@@ -14,8 +14,8 @@ files/frontcontroller13.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(4) "test"
-string(12) "oof/test.php"
+%string|unicode%(4) "test"
+%string|unicode%(12) "oof/test.php"
Warning: include(./hi.php): failed to open stream: No such file or directory in phar://%s/oof/test.php on line %d
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt
index 66587de02..d6c469d9c 100755
--- a/ext/phar/tests/create_new_and_modify.phpt
+++ b/ext/phar/tests/create_new_and_modify.phpt
@@ -27,9 +27,9 @@ file_put_contents($pname .'/b.php', "another!\n");
$phar = new Phar($fname);
$sig2 = $phar->getSignature();
-var_dump($sig1['hash']);
-var_dump($sig2['hash']);
-var_dump($sig1['hash'] != $sig2['hash']);
+var_dump($sig1[b'hash']);
+var_dump($sig2[b'hash']);
+var_dump($sig1[b'hash'] != $sig2[b'hash']);
include $pname . '/a.php';
include $pname . '/b.php';
diff --git a/ext/phar/tests/files/frontcontroller12.phar b/ext/phar/tests/files/frontcontroller12.phar
index 9e4558761..315c2901e 100644
--- a/ext/phar/tests/files/frontcontroller12.phar
+++ b/ext/phar/tests/files/frontcontroller12.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller12.phar.inc b/ext/phar/tests/files/frontcontroller12.phar.inc
index ba17df37e..f1e4645e2 100644
--- a/ext/phar/tests/files/frontcontroller12.phar.inc
+++ b/ext/phar/tests/files/frontcontroller12.phar.inc
@@ -3,13 +3,13 @@
$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"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
';
$a->setStub('<?php
Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
diff --git a/ext/phar/tests/files/frontcontroller14.phar b/ext/phar/tests/files/frontcontroller14.phar
index 78a42a999..2bca00665 100644
--- a/ext/phar/tests/files/frontcontroller14.phar
+++ b/ext/phar/tests/files/frontcontroller14.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller14.phar.inc b/ext/phar/tests/files/frontcontroller14.phar.inc
index d0ebd9a45..23104a642 100644
--- a/ext/phar/tests/files/frontcontroller14.phar.inc
+++ b/ext/phar/tests/files/frontcontroller14.phar.inc
@@ -2,8 +2,8 @@
@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"]);
+var_dump($_SERVER[b"PATH_INFO"]);
+var_dump($_SERVER[b"PATH_TRANSLATED"]);
';
$a->setStub('<?php
function s($a)
diff --git a/ext/phar/tests/files/frontcontroller3.phar b/ext/phar/tests/files/frontcontroller3.phar
index afcf03af3..5c5ff9cae 100644
--- a/ext/phar/tests/files/frontcontroller3.phar
+++ b/ext/phar/tests/files/frontcontroller3.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller3.phar.inc b/ext/phar/tests/files/frontcontroller3.phar.inc
index 2759d9ee4..c2095947b 100644
--- a/ext/phar/tests/files/frontcontroller3.phar.inc
+++ b/ext/phar/tests/files/frontcontroller3.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => "a.phps");
+ static $b = array(b"/hi" => b"a.phps");
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/files/frontcontroller4.phar b/ext/phar/tests/files/frontcontroller4.phar
index 4c9a92a19..004d1ffd1 100644
--- a/ext/phar/tests/files/frontcontroller4.phar
+++ b/ext/phar/tests/files/frontcontroller4.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller4.phar.inc b/ext/phar/tests/files/frontcontroller4.phar.inc
index 5c6a43f95..daf807e41 100644
--- a/ext/phar/tests/files/frontcontroller4.phar.inc
+++ b/ext/phar/tests/files/frontcontroller4.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => false);
+ static $b = array(b"/hi" => false);
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/files/frontcontroller8.phar b/ext/phar/tests/files/frontcontroller8.phar
index ec05ceafb..27280a327 100644
--- a/ext/phar/tests/files/frontcontroller8.phar
+++ b/ext/phar/tests/files/frontcontroller8.phar
Binary files differ
diff --git a/ext/phar/tests/files/frontcontroller8.phar.inc b/ext/phar/tests/files/frontcontroller8.phar.inc
index 1dfb654a0..8629f0890 100644
--- a/ext/phar/tests/files/frontcontroller8.phar.inc
+++ b/ext/phar/tests/files/frontcontroller8.phar.inc
@@ -2,7 +2,7 @@
@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['a1.phps'] = '<?php var_dump($_SERVER[b"REQUEST_URI"], $_SERVER[b"PATH_INFO"]);';
$a['a.jpg'] = 'hio2';
$a['a.php'] = '<?php function hio(){}';
$a['fronk.gronk'] = 'hio3';
diff --git a/ext/phar/tests/fopen_edgecases2.phpt b/ext/phar/tests/fopen_edgecases2.phpt
index c606024ad..6c5ac7b45 100644
--- a/ext/phar/tests/fopen_edgecases2.phpt
+++ b/ext/phar/tests/fopen_edgecases2.phpt
@@ -2,6 +2,7 @@
Phar: test edge cases of fopen() function interception #2
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(php_version(), '6.0', '>=')) die('skip parameter parsing changed in 6.0'); ?>
--INI--
phar.readonly=0
--FILE--
@@ -12,14 +13,14 @@ $pname = 'phar://' . $fname;
fopen(array(), 'r');
chdir(dirname(__FILE__));
-file_put_contents($fname, "blah\n");
-file_put_contents("foob", "test\n");
+file_put_contents($fname, b"blah\n");
+file_put_contents("foob", b"test\n");
$a = fopen($fname, 'rb');
echo fread($a, 1000);
fclose($a);
unlink($fname);
mkdir($pname . '/oops');
-file_put_contents($pname . '/foo/hi', '<?php
+file_put_contents($pname . '/foo/hi', b'<?php
$context = stream_context_create();
$a = fopen("foob", "rb", false, $context);
echo fread($a, 1000);
diff --git a/ext/phar/tests/fopen_edgecases2U.phpt b/ext/phar/tests/fopen_edgecases2U.phpt
new file mode 100644
index 000000000..09c7b0057
--- /dev/null
+++ b/ext/phar/tests/fopen_edgecases2U.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Phar: test edge cases of fopen() function interception #2 (PHP 6)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "6.0.0-dev", "<")) die("skip Unicode support required"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+fopen(array(), 'r');
+chdir(dirname(__FILE__));
+file_put_contents($fname, b"blah\n");
+file_put_contents("foob", b"test\n");
+$a = fopen($fname, 'rb');
+echo fread($a, 1000);
+fclose($a);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', b'<?php
+$context = stream_context_create();
+$a = fopen("foob", "rb", false, $context);
+echo fread($a, 1000);
+fclose($a);
+fopen("../oops", "r");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+Notice: Array to string conversion in %sfopen_edgecases2U.php on line 6
+
+Warning: fopen(Array): failed to open stream: No such file or directory in %sfopen_edgecases2U.php on line 6
+blah
+test
+
+Warning: fopen(phar://%sfopen_edgecases2U.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2U.phar.php/foo/hi on line 6
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/frontcontroller21.phpt b/ext/phar/tests/frontcontroller21.phpt
index dcdbf575f..bf50c6e80 100644
--- a/ext/phar/tests/frontcontroller21.phpt
+++ b/ext/phar/tests/frontcontroller21.phpt
@@ -14,7 +14,7 @@ files/frontcontroller12.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(10) "/index.php"
+%unicode|string%(10) "/index.php"
string(10) "/index.php"
string(%d) "phar://%sfrontcontroller21.php/index.php"
string(18) "/index.php?test=hi"
diff --git a/ext/phar/tests/frontcontroller22.phpt b/ext/phar/tests/frontcontroller22.phpt
index 827c5688c..b85c1eb49 100644
--- a/ext/phar/tests/frontcontroller22.phpt
+++ b/ext/phar/tests/frontcontroller22.phpt
@@ -13,8 +13,8 @@ files/frontcontroller13.phar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(4) "test"
-string(12) "oof/test.php"
+%unicode|string%(4) "test"
+%unicode|string%(12) "oof/test.php"
Warning: include(./hi.php): failed to open stream: No such file or directory in phar://%s/oof/test.php on line %d
diff --git a/ext/phar/tests/ini_set.phpt b/ext/phar/tests/ini_set.phpt
index 01dc99589..7ccd6ea12 100644
--- a/ext/phar/tests/ini_set.phpt
+++ b/ext/phar/tests/ini_set.phpt
@@ -3,7 +3,6 @@ Phar: test ini_set with readonly and require_hash enabled
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=1
@@ -14,18 +13,22 @@ var_dump(ini_set('phar.require_hash', 1));
var_dump(ini_set('phar.readonly', 1));
var_dump(ini_get('phar.require_hash'));
var_dump(ini_get('phar.readonly'));
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+var_dump(false, false);
+} else {
var_dump(ini_set('phar.require_hash', 0));
var_dump(ini_set('phar.readonly', 0));
+}
var_dump(ini_get('phar.require_hash'));
var_dump(ini_get('phar.readonly'));
__HALT_COMPILER();
?>
---EXPECT--
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
+--EXPECTF--
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
bool(false)
bool(false)
-string(1) "1"
-string(1) "1"
+%unicode|string%(1) "1"
+%unicode|string%(1) "1"
diff --git a/ext/phar/tests/ini_setU.phpt b/ext/phar/tests/ini_setU.phpt
deleted file mode 100644
index 470040f7b..000000000
--- a/ext/phar/tests/ini_setU.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Phar: test ini_set with readonly and require_hash enabled
---SKIPIF--
-<?php
-if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
-?>
---INI--
-phar.require_hash=1
-phar.readonly=1
---FILE--
-<?php
-var_dump(ini_set('phar.require_hash', 1));
-var_dump(ini_set('phar.readonly', 1));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-var_dump(ini_set('phar.require_hash', 0));
-var_dump(ini_set('phar.readonly', 0));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-__HALT_COMPILER();
-?>
---EXPECT--
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
-unicode(1) "1"
diff --git a/ext/phar/tests/phar_buildfromiterator10.phpt b/ext/phar/tests/phar_buildfromiterator10.phpt
index 4dc3af7cc..024277ed0 100644
--- a/ext/phar/tests/phar_buildfromiterator10.phpt
+++ b/ext/phar/tests/phar_buildfromiterator10.phpt
@@ -3,7 +3,6 @@ Phar::buildFromIterator() RegexIterator(RecursiveIteratorIterator), SplFileInfo
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
?>
--INI--
phar.require_hash=0
diff --git a/ext/phar/tests/phar_buildfromiterator10U.phpt b/ext/phar/tests/phar_buildfromiterator10U.phpt
deleted file mode 100644
index 74f41597a..000000000
--- a/ext/phar/tests/phar_buildfromiterator10U.phpt
+++ /dev/null
@@ -1,101 +0,0 @@
---TEST--
-Phar::buildFromIterator() RegexIterator(RecursiveIteratorIterator), SplFileInfo as current
---SKIPIF--
-<?php
-if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
-?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-try {
- chdir(dirname(__FILE__));
- $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
- $dir = new RecursiveDirectoryIterator('.');
- $iter = new RecursiveIteratorIterator($dir);
- $a = $phar->buildFromIterator(new RegexIterator($iter, '/_\d{3}\.phpt$/'), dirname(__FILE__) . DIRECTORY_SEPARATOR);
- asort($a);
- var_dump($a);
-} catch (Exception $e) {
- var_dump(get_class($e));
- echo $e->getMessage() . "\n";
-}
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/buildfromiterator.phar');
-__HALT_COMPILER();
-?>
---EXPECTF--
-array(33) {
- ["phar_ctx_001.phpt"]=>
- unicode(%d) "%sphar_ctx_001.phpt"
- ["phar_get_supported_signatures_001.phpt"]=>
- unicode(%d) "%sphar_get_supported_signatures_001.phpt"
- ["phar_get_supported_signatures_002.phpt"]=>
- unicode(%d) "%sphar_get_supported_signatures_002.phpt"
- ["phar_oo_001.phpt"]=>
- unicode(%d) "%sphar_oo_001.phpt"
- ["phar_oo_002.phpt"]=>
- unicode(%d) "%sphar_oo_002.phpt"
- ["phar_oo_003.phpt"]=>
- unicode(%d) "%sphar_oo_003.phpt"
- ["phar_oo_004.phpt"]=>
- unicode(%d) "%sphar_oo_004.phpt"
- ["phar_oo_005.phpt"]=>
- unicode(%d) "%sphar_oo_005.phpt"
- ["phar_oo_006.phpt"]=>
- unicode(%d) "%sphar_oo_006.phpt"
- ["phar_oo_007.phpt"]=>
- unicode(%d) "%sphar_oo_007.phpt"
- ["phar_oo_008.phpt"]=>
- unicode(%d) "%sphar_oo_008.phpt"
- ["phar_oo_009.phpt"]=>
- unicode(%d) "%sphar_oo_009.phpt"
- ["phar_oo_010.phpt"]=>
- unicode(%d) "%sphar_oo_010.phpt"
- ["phar_oo_011.phpt"]=>
- unicode(%d) "%sphar_oo_011.phpt"
- ["phar_oo_012.phpt"]=>
- unicode(%d) "%sphar_oo_012.phpt"
- ["phar_oo_compressed_001.phpt"]=>
- unicode(%d) "%sphar_oo_compressed_001.phpt"
- ["phar_oo_compressed_002.phpt"]=>
- unicode(%d) "%sphar_oo_compressed_002.phpt"
- ["phpinfo_001.phpt"]=>
- unicode(%d) "%sphpinfo_001.phpt"
- ["phpinfo_002.phpt"]=>
- unicode(%d) "%sphpinfo_002.phpt"
- ["phpinfo_003.phpt"]=>
- unicode(%d) "%sphpinfo_003.phpt"
- ["phpinfo_004.phpt"]=>
- unicode(%d) "%sphpinfo_004.phpt"
- ["tar/tar_001.phpt"]=>
- unicode(%d) "%star%ctar_001.phpt"
- ["tar/tar_002.phpt"]=>
- unicode(%d) "%star%ctar_002.phpt"
- ["tar/tar_003.phpt"]=>
- unicode(%d) "%star%ctar_003.phpt"
- ["tar/tar_004.phpt"]=>
- unicode(%d) "%star%ctar_004.phpt"
- ["zip/corrupt_001.phpt"]=>
- unicode(%d) "%szip%ccorrupt_001.phpt"
- ["zip/corrupt_002.phpt"]=>
- unicode(%d) "%szip%ccorrupt_002.phpt"
- ["zip/corrupt_003.phpt"]=>
- unicode(%d) "%szip%ccorrupt_003.phpt"
- ["zip/corrupt_004.phpt"]=>
- unicode(%d) "%szip%ccorrupt_004.phpt"
- ["zip/corrupt_005.phpt"]=>
- unicode(%d) "%szip%ccorrupt_005.phpt"
- ["zip/corrupt_006.phpt"]=>
- unicode(%d) "%szip%ccorrupt_006.phpt"
- ["zip/corrupt_007.phpt"]=>
- unicode(%d) "%szip%ccorrupt_007.phpt"
- ["zip/corrupt_008.phpt"]=>
- unicode(%d) "%szip%ccorrupt_008.phpt"
-}
-===DONE===
diff --git a/ext/phar/tests/phar_bz2.phpt b/ext/phar/tests/phar_bz2.phpt
index 6e05663d5..0e6e3ecb5 100644
--- a/ext/phar/tests/phar_bz2.phpt
+++ b/ext/phar/tests/phar_bz2.phpt
@@ -3,7 +3,6 @@ Phar: bzipped phar
--SKIPIF--
<?php
if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
if (!extension_loaded("spl")) die("skip SPL not available");
if (!extension_loaded("bz2")) die("skip bz2 not available");
?>
@@ -56,8 +55,8 @@ echo $e->getMessage(),"\n";
@unlink(dirname(__FILE__) . '/phar_bz2.2.phar');
?>
--EXPECTF--
-string(9) "it worked"
-string(%d) "phar://%sphar_bz2.phar/tar_004.php"
+%unicode|string%(9) "it worked"
+%unicode|string%(%d) "phar://%sphar_bz2.phar/tar_004.php"
bool(true)
bool(true)
diff --git a/ext/phar/tests/phar_bz2U.phpt b/ext/phar/tests/phar_bz2U.phpt
deleted file mode 100644
index 62f5c5812..000000000
--- a/ext/phar/tests/phar_bz2U.phpt
+++ /dev/null
@@ -1,66 +0,0 @@
---TEST--
-Phar: bzipped phar
---SKIPIF--
-<?php
-if (!extension_loaded("phar")) die("skip");
-if (version_compare(PHP_VERSION, "6.0", "<")) die("skip Unicode support required");
-if (!extension_loaded("spl")) die("skip SPL not available");
-if (!extension_loaded("bz2")) die("skip bz2 not available");
-?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/phar_bz2U.phar';
-$pname = 'phar://' . $fname;
-$fname2 = dirname(__FILE__) . '/phar_bz2U.2.phar';
-$pname2 = 'phar://' . $fname2;
-
-$file = '<?php
-Phar::mapPhar();
-var_dump("it worked");
-include "phar://" . __FILE__ . "/tar_004.php";
-__HALT_COMPILER();';
-
-$files = array();
-$files['tar_004.php'] = '<?php var_dump(__FILE__);';
-$files['internal/file/here'] = "hi there!\n";
-$files['internal/dir/'] = '';
-$files['dir/'] = '';
-$bz2 = true;
-
-include 'files/phar_test.inc';
-
-include $fname;
-
-$a = new Phar($fname);
-$a['test'] = 'hi';
-copy($fname, $fname2);
-$a->setAlias('another');
-$b = new Phar($fname2);
-var_dump($b->isFileFormat(Phar::PHAR));
-var_dump($b->isCompressed() == Phar::BZ2);
-// additional code coverage
-$b->isFileFormat(array());
-try {
-$b->isFileFormat(25);
-} catch (Exception $e) {
-echo $e->getMessage(),"\n";
-}
-?>
-===DONE===
---CLEAN--
-<?php
-@unlink(dirname(__FILE__) . '/phar_bz2U.phar');
-@unlink(dirname(__FILE__) . '/phar_bz2U.2.phar');
-?>
---EXPECTF--
-unicode(9) "it worked"
-unicode(%d) "phar://%sphar_bz2U.phar/tar_004.php"
-bool(true)
-bool(true)
-
-Warning: Phar::isFileFormat() expects parameter 1 to be long, array given in %sphar_bz2U.php on line %d
-Unknown file format specified
-===DONE===
diff --git a/ext/phar/tests/phar_convert_again.phpt b/ext/phar/tests/phar_convert_again.phpt
index 9485f1e6a..bbf2c6633 100644
--- a/ext/phar/tests/phar_convert_again.phpt
+++ b/ext/phar/tests/phar_convert_again.phpt
@@ -62,11 +62,6 @@ $data->setAlias('hi');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
-try {
-$data->setSignatureAlgorithm(Phar::MD5);
-} catch (Exception $e) {
-echo $e->getMessage() . "\n";
-}
$tar = $phar->convertToExecutable(Phar::TAR);
echo $tar->getPath() . "\n";
$data = $tar->convertToData();
@@ -188,7 +183,6 @@ hi
A Phar stub cannot be set in a plain zip archive
A Phar stub cannot be set in a plain zip archive
A Phar alias cannot be set in a plain zip archive
-Cannot set signature algorithm, not possible with zip-based phar archives
%sphar_convert_again2.phar.tar
%sphar_convert_again2.tar
%sphar_convert_again2.phar.tar.gz
diff --git a/ext/phar/tests/phar_ctx_001.phpt b/ext/phar/tests/phar_ctx_001.phpt
index 14b7afc71..72edc5a99 100644
--- a/ext/phar/tests/phar_ctx_001.phpt
+++ b/ext/phar/tests/phar_ctx_001.phpt
@@ -28,7 +28,7 @@ var_dump($phar['b']->isCompressed());
var_dump(file_get_contents($pname . '/c'));
var_dump($phar['c']->isCompressed());
-$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, 'hi' => 3))));
+$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, b'hi' => 3))));
$context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
file_put_contents($pname . '/a', b'new a', 0); // no compression
diff --git a/ext/phar/tests/phar_magic.phpt b/ext/phar/tests/phar_magic.phpt
index f6a0a675e..7c60589f9 100644
--- a/ext/phar/tests/phar_magic.phpt
+++ b/ext/phar/tests/phar_magic.phpt
@@ -14,6 +14,9 @@ $p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_
$p['d'] = "in d\n";
$p->setStub('<?php
set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $fname;
diff --git a/ext/phar/tests/readfile_edgecases.phpt b/ext/phar/tests/readfile_edgecases.phpt
index 1a78d7b5b..2c93c8b22 100644
--- a/ext/phar/tests/readfile_edgecases.phpt
+++ b/ext/phar/tests/readfile_edgecases.phpt
@@ -2,6 +2,7 @@
Phar: test edge cases of readfile() function interception
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?>
--INI--
phar.readonly=0
--FILE--
diff --git a/ext/phar/tests/readfile_edgecasesU.phpt b/ext/phar/tests/readfile_edgecasesU.phpt
new file mode 100644
index 000000000..c26b45fc5
--- /dev/null
+++ b/ext/phar/tests/readfile_edgecasesU.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Phar: test edge cases of readfile() function interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (version_compare(PHP_VERSION, "6.0", "<")) die("skip requires php 6.0 or newer"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+
+chdir(dirname(__FILE__));
+file_put_contents($fname, "blah\n");
+file_put_contents("foob", "test\n");
+readfile($fname);
+unlink($fname);
+mkdir($pname . '/oops');
+file_put_contents($pname . '/foo/hi', '<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("' . addslashes(dirname(__FILE__)) . '");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+');
+include $pname . '/foo/hi';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php rmdir(dirname(__FILE__) . '/poo'); ?>
+<?php unlink(dirname(__FILE__) . '/foob'); ?>
+--EXPECTF--
+blah
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+test
+test
+<?php
+readfile("foo/" . basename(__FILE__));
+$context = stream_context_create();
+readfile("foob");
+set_include_path("%stests");
+readfile("foob", true);
+readfile("./hi", 0, $context);
+readfile("../oops");
+?>
+
+Warning: readfile(phar://%sreadfile_edgecasesU.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecasesU.phar.php/foo/hi on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/tar/bignames.phpt b/ext/phar/tests/tar/bignames.phpt
index 4b51e2a92..c10b1cea2 100644
--- a/ext/phar/tests/tar/bignames.phpt
+++ b/ext/phar/tests/tar/bignames.phpt
@@ -8,30 +8,50 @@ phar.require_hash=0
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.tar';
+$fname4 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.4.tar';
$pname = 'phar://' . $fname;
$p1 = new PharData($fname);
-$p1[str_repeat('a', 101)] = 'hi';
-$p1[str_repeat('a', 255)] = 'hi2';
+$p1[str_repeat('a', 100) . '/b'] = 'hi';
+$p1[str_repeat('a', 155) . '/' . str_repeat('b', 100)] = 'hi2';
copy($fname, $fname2);
$p2 = new PharData($fname2);
-echo $p2[str_repeat('a', 101)]->getContent() . "\n";
-echo $p2[str_repeat('a', 255)]->getContent() . "\n";
+echo $p2[str_repeat('a', 100) . '/b']->getContent() . "\n";
+echo $p2[str_repeat('a', 155) . '/' . str_repeat('b', 100)]->getContent() . "\n";
try {
$p2[str_repeat('a', 400)] = 'yuck';
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
+
+try {
+ $p2 = new PharData($fname3);
+ $p2[str_repeat('a', 101)] = 'yuck';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $p2 = new PharData($fname4);
+ $p2[str_repeat('b', 160) . '/' . str_repeat('a', 90)] = 'yuck';
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
?>
===DONE===
--CLEAN--
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
+@unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.tar');
+@unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.4.tar');
?>
--EXPECTF--
hi
hi2
tar-based phar "%sbignames.2.tar" cannot be created, filename "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
+tar-based phar "%sbignames.3.tar" cannot be created, filename "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
+tar-based phar "%sbignames.4.tar" cannot be created, filename "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is too long for tar file format
===DONE===
diff --git a/ext/phar/tests/tar/bignames_overflow.phpt b/ext/phar/tests/tar/bignames_overflow.phpt
index 80873119f..359e9c634 100644
--- a/ext/phar/tests/tar/bignames_overflow.phpt
+++ b/ext/phar/tests/tar/bignames_overflow.phpt
@@ -22,8 +22,8 @@ $p1 = new PharData($fname);
foreach ($p1 as $file) {
echo $file->getFileName(), "\n";
}
-echo $p1[str_repeat('a', 101)]->getContent() . "\n";
-echo $p1[str_repeat('a', 255)]->getContent() . "\n";
+echo $p1['a/' . str_repeat('a', 100)]->getContent() . "\n";
+echo $p1[str_repeat('a', 155) . '/' . str_repeat('a', 100)]->getContent() . "\n";
?>
===DONE===
@@ -33,8 +33,8 @@ unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
?>
--EXPECT--
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+a
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
hi
hi2
===DONE===
diff --git a/ext/phar/tests/tar/bug49910.phpt b/ext/phar/tests/tar/bug49910.phpt
new file mode 100644
index 000000000..6fb66a50a
--- /dev/null
+++ b/ext/phar/tests/tar/bug49910.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug #49910: no support for ././@LongLink for long filenames in phar tar support
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip"); ?>
+--FILE--
+<?php
+$fname = str_replace('\\', '/', dirname(__FILE__) . '/files/Structures_Graph-1.0.3.tgz');
+$tar = new PharData($fname);
+$files = array();
+foreach (new RecursiveIteratorIterator($tar) as $file) {
+ $files[] = str_replace($fname, '*', $file->getPathName());
+}
+print_r($files);
+?>
+===DONE===
+--EXPECT--
+Array
+(
+ [0] => phar://*/Structures_Graph-1.0.3/LICENSE
+ [1] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/AcyclicTest.php
+ [2] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/TopologicalSorter.php
+ [3] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Node.php
+ [4] => phar://*/Structures_Graph-1.0.3/Structures/Graph.php
+ [5] => phar://*/Structures_Graph-1.0.3/docs/generate.sh
+ [6] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph.html
+ [7] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_AcyclicTest.html
+ [8] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_TopologicalSorter.html
+ [9] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Node.html
+ [10] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_AcyclicTest_php.html
+ [11] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_TopologicalSorter_php.html
+ [12] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Node_php.html
+ [13] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_php.html
+ [14] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/tutorial_Structures_Graph.pkg.html
+ [15] => phar://*/Structures_Graph-1.0.3/docs/html/classtrees_Structures_Graph.html
+ [16] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex.html
+ [17] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex_Structures_Graph.html
+ [18] => phar://*/Structures_Graph-1.0.3/docs/html/errors.html
+ [19] => phar://*/Structures_Graph-1.0.3/docs/html/index.html
+ [20] => phar://*/Structures_Graph-1.0.3/docs/html/li_Structures_Graph.html
+ [21] => phar://*/Structures_Graph-1.0.3/docs/html/media/banner.css
+ [22] => phar://*/Structures_Graph-1.0.3/docs/html/media/stylesheet.css
+ [23] => phar://*/Structures_Graph-1.0.3/docs/html/packages.html
+ [24] => phar://*/Structures_Graph-1.0.3/docs/html/todolist.html
+ [25] => phar://*/Structures_Graph-1.0.3/docs/tutorials/Structures_Graph/Structures_Graph.pkg
+ [26] => phar://*/Structures_Graph-1.0.3/tests/AllTests.php
+ [27] => phar://*/Structures_Graph-1.0.3/tests/testCase/BasicGraph.php
+ [28] => phar://*/package.xml
+)
+===DONE===
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz b/ext/phar/tests/tar/files/P1-1.0.0.tgz
new file mode 100644
index 000000000..1d9cae439
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
new file mode 100644
index 000000000..eb59bdd26
--- /dev/null
+++ b/ext/phar/tests/tar/files/P1-1.0.0.tgz.pubkey
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4drcwddPs6LmIbdT1ifT
+Ev8HXh1Fk1yNusCDoCX6mYkgqvCmx02F/9k5q7n6CPblTcF5mdDI8kcRrUHmyXtD
+9X0d7RN7BakZMPH5KPaNkXiXsI9YGSb39AnZgYw01n6u0W6Ohha+KwOsrxkKCF4u
+LjPLQAlM+3uD8y9Tz2fF+pAE901kHrd3ue7a5i5EtW0bzl5QfxnwFZXAO0StQ9dF
+slzibRH+1pFjMRxDnlgYmLQF6jMWm9Ty6x9UH9HZ3E3F9QZEQVXWT9y/pe30HcAX
+YxAGZjPIx19UNPF5C+Nps6MjxNRht0pGXTL9sptYoiNjRiXAS0y4FM+8K6xvBIOF
+ZQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
new file mode 100644
index 000000000..fa14f0c6a
--- /dev/null
+++ b/ext/phar/tests/tar/files/Structures_Graph-1.0.3.tgz
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.inc b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
index 693ef0aa0..0a9422a29 100644
--- a/ext/phar/tests/tar/files/frontcontroller12.phar.inc
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.inc
@@ -3,13 +3,13 @@
$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.tar');
$a['index.php'] = '<?php
var_dump($_SERVER["PHP_SELF"]);
-var_dump($_SERVER["SCRIPT_NAME"]);
-var_dump($_SERVER["SCRIPT_FILENAME"]);
-var_dump($_SERVER["REQUEST_URI"]);
-var_dump($_SERVER["PHAR_PHP_SELF"]);
-var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
-var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
-var_dump($_SERVER["PHAR_REQUEST_URI"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
';
$a->setStub('<?php
Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.tar b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
index e0f22f5f4..e945e49bd 100644
--- a/ext/phar/tests/tar/files/frontcontroller12.phar.tar
+++ b/ext/phar/tests/tar/files/frontcontroller12.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.inc b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
index 9729d0065..800f65e81 100644
--- a/ext/phar/tests/tar/files/frontcontroller3.phar.inc
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => "a.phps");
+ static $b = array(b"/hi" => b"a.phps");
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.tar b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
index 2df61c95a..16853bd10 100644
--- a/ext/phar/tests/tar/files/frontcontroller3.phar.tar
+++ b/ext/phar/tests/tar/files/frontcontroller3.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.inc b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
index eb1d56f0d..bfb9b4104 100644
--- a/ext/phar/tests/tar/files/frontcontroller4.phar.inc
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => false);
+ static $b = array(b"/hi" => false);
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.tar b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
index 4cd684d25..5a1d4ee10 100644
--- a/ext/phar/tests/tar/files/frontcontroller4.phar.tar
+++ b/ext/phar/tests/tar/files/frontcontroller4.phar.tar
Binary files differ
diff --git a/ext/phar/tests/tar/frontcontroller21.phar.phpt b/ext/phar/tests/tar/frontcontroller21.phar.phpt
index c1a299cc9..bb93996d6 100644
--- a/ext/phar/tests/tar/frontcontroller21.phar.phpt
+++ b/ext/phar/tests/tar/frontcontroller21.phar.phpt
@@ -14,7 +14,7 @@ files/frontcontroller12.phar.tar
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(10) "/index.php"
+%unicode|string%(10) "/index.php"
string(10) "/index.php"
string(%d) "phar://%sfrontcontroller21.phar.php/index.php"
string(18) "/index.php?test=hi"
diff --git a/ext/phar/tests/tar/phar_convert_phar4.phpt b/ext/phar/tests/tar/phar_convert_phar4.phpt
index f23780e1a..9b095f11c 100644
--- a/ext/phar/tests/tar/phar_convert_phar4.phpt
+++ b/ext/phar/tests/tar/phar_convert_phar4.phpt
@@ -14,7 +14,7 @@ $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
$phar = new Phar($fname);
$phar['a.txt'] = 'some text';
-$phar->setMetadata('hi');
+$phar->setMetadata(b'hi');
$phar->stopBuffering();
var_dump($phar->isFileFormat(Phar::TAR));
var_dump(strlen($phar->getStub()));
diff --git a/ext/phar/tests/tar/phar_magic.phpt b/ext/phar/tests/tar/phar_magic.phpt
index 1bb336f96..ed0a46297 100644
--- a/ext/phar/tests/tar/phar_magic.phpt
+++ b/ext/phar/tests/tar/phar_magic.phpt
@@ -15,6 +15,9 @@ $p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_
$p['d'] = "in d\n";
$p->setStub('<?php
set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $fname;
diff --git a/ext/phar/tests/tar/tar_openssl_hash.phpt b/ext/phar/tests/tar/tar_openssl_hash.phpt
new file mode 100644
index 000000000..49ef77a44
--- /dev/null
+++ b/ext/phar/tests/tar/tar_openssl_hash.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Phar: tar archive, require_hash=1, OpenSSL hash
+--SKIPIF--
+<?php if (!extension_loaded('phar')) die('skip'); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+<?php if (!extension_loaded("openssl")) die("skip openssl not available"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=1
+--FILE--
+<?php
+try {
+ $phar = new PharData(dirname(__FILE__) . '/files/P1-1.0.0.tgz');
+} catch (Exception $e) {
+ echo $e->getMessage()."\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/phar/tests/zip/all.phpt b/ext/phar/tests/zip/all.phpt
index 7fcb5f368..49d79a44c 100644
--- a/ext/phar/tests/zip/all.phpt
+++ b/ext/phar/tests/zip/all.phpt
@@ -46,6 +46,7 @@ var_dump($phar['a']->getMetadata());
?>
===DONE===
--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?>
--EXPECT--
bool(false)
diff --git a/ext/phar/tests/zip/bug48791.phpt b/ext/phar/tests/zip/bug48791.phpt
new file mode 100644
index 000000000..45c527188
--- /dev/null
+++ b/ext/phar/tests/zip/bug48791.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Phar: Bug #48791: open office documents always reported as corrupted by phar extension
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
+--FILE--
+<?php
+echo file_get_contents('phar://' . dirname(__FILE__) . '/files/test.odt/content.xml'), "\n";
+?>
+===DONE===
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/><style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/><style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="MS Mincho" svg:font-family="&apos;MS Mincho&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L1"/><style:style style:name="T1" style:family="text"><style:text-properties style:font-name="Arial"/></style:style><text:list-style style:name="L1"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:h text:style-name="Heading_20_1" text:outline-level="1">Überschrift</text:h><text:list xml:id="list38593008" text:style-name="L1"><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Name:<text:tab/><text:tab/>$$n_fn$$</text:span></text:p></text:list-item><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Firma:<text:tab/><text:tab/>$$org_name$$</text:span></text:p></text:list-item><text:list-item><text:p text:style-name="P1"><text:span text:style-name="T1">Menge:<text:tab/>$$#menge$$</text:span></text:p></text:list-item></text:list></office:text></office:body></office:document-content>
+===DONE===
diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
index 7c3b356c2..b993ff553 100644
--- a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
+++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
@@ -26,7 +26,7 @@
* @author Vincent Lascaux <vincentlascaux@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.gnu.org/copyleft/lesser.html LGPL
- * @version CVS: $Id: corrupt_zipmaker.php.inc,v 1.5.2.2 2008/08/11 22:43:02 cellog Exp $
+ * @version CVS: $Id: corrupt_zipmaker.php.inc 264655 2008-08-11 22:43:02Z cellog $
* @link http://pear.php.net/package/File_Archive
*/
diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
index 77c4a1dd0..c5f38ffd1 100644
--- a/ext/phar/tests/zip/files/frontcontroller12.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
@@ -3,13 +3,13 @@
$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.zip');
$a['index.php'] = '<?php
var_dump($_SERVER["PHP_SELF"]);
-var_dump($_SERVER["SCRIPT_NAME"]);
-var_dump($_SERVER["SCRIPT_FILENAME"]);
-var_dump($_SERVER["REQUEST_URI"]);
-var_dump($_SERVER["PHAR_PHP_SELF"]);
-var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
-var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
-var_dump($_SERVER["PHAR_REQUEST_URI"]);
+var_dump($_SERVER[b"SCRIPT_NAME"]);
+var_dump($_SERVER[b"SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"REQUEST_URI"]);
+var_dump($_SERVER[b"PHAR_PHP_SELF"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_NAME"]);
+var_dump($_SERVER[b"PHAR_SCRIPT_FILENAME"]);
+var_dump($_SERVER[b"PHAR_REQUEST_URI"]);
';
$a->setStub('<?php
Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.zip b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
index e831e4430..ed9be3d00 100644
--- a/ext/phar/tests/zip/files/frontcontroller12.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
index ab28f7b3d..ccd55b73f 100644
--- a/ext/phar/tests/zip/files/frontcontroller3.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => "a.phps");
+ static $b = array(b"/hi" => b"a.phps");
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.zip b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
index f167f2f6e..6f35a8042 100644
--- a/ext/phar/tests/zip/files/frontcontroller3.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
index d78399142..9f664cf2c 100644
--- a/ext/phar/tests/zip/files/frontcontroller4.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
@@ -7,7 +7,7 @@ $a['a.phps'] = '<?php function hio(){}';
$a->setStub('<?php
function s($a)
{
- static $b = array("/hi" => false);
+ static $b = array(b"/hi" => false);
if (isset($b[$a])) return $b[$a];
return $a;
}
diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.zip b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
index 1ad83f8a6..fb27ccb0b 100644
--- a/ext/phar/tests/zip/files/frontcontroller4.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/files/test.odt b/ext/phar/tests/zip/files/test.odt
new file mode 100644
index 000000000..c5cefe58e
--- /dev/null
+++ b/ext/phar/tests/zip/files/test.odt
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller21.phar.phpt b/ext/phar/tests/zip/frontcontroller21.phar.phpt
index d0a16c5d9..74caa2c81 100644
--- a/ext/phar/tests/zip/frontcontroller21.phar.phpt
+++ b/ext/phar/tests/zip/frontcontroller21.phar.phpt
@@ -15,7 +15,7 @@ files/frontcontroller12.phar.zip
--EXPECTHEADERS--
Content-type: text/html; charset=UTF-8
--EXPECTF--
-string(10) "/index.php"
+%unicode|string%(10) "/index.php"
string(10) "/index.php"
string(%d) "phar://%sfrontcontroller21.phar.php/index.php"
string(18) "/index.php?test=hi"
diff --git a/ext/phar/tests/zip/phar_magic.phpt b/ext/phar/tests/zip/phar_magic.phpt
index a56639d7e..694f92777 100644
--- a/ext/phar/tests/zip/phar_magic.phpt
+++ b/ext/phar/tests/zip/phar_magic.phpt
@@ -21,6 +21,9 @@ $p->setStub('<?php
var_dump(__FILE__);
var_dump(substr(__FILE__, 0, 4) != "phar");
set_include_path("phar://" . __FILE__);
+if (version_compare(PHP_VERSION, "5.3", "<")) {
+Phar::interceptFileFuncs();
+}
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $pname;
diff --git a/ext/phar/tests/zip/phar_setsignaturealgo2.phpt b/ext/phar/tests/zip/phar_setsignaturealgo2.phpt
new file mode 100644
index 000000000..372f7ddc8
--- /dev/null
+++ b/ext/phar/tests/zip/phar_setsignaturealgo2.phpt
@@ -0,0 +1,113 @@
+--TEST--
+Phar::setSupportedSignatures() with hash, zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("hash")) die("skip extension hash required");
+$arr = Phar::getSupportedSignatures();
+if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
+if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
+--INI--
+phar.require_hash=0
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
+$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar.zip';
+$fname4 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.4.phar.zip';
+$fname5 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.5.phar.zip';
+$fname6 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.6.phar.zip';
+$p = new Phar($fname);
+$p['file1.txt'] = 'hi';
+var_dump($p->getSignature());
+$p->setSignatureAlgorithm(Phar::MD5);
+
+copy($fname, $fname2);
+$p = new Phar($fname2);
+var_dump($p->getSignature());
+
+$p->setSignatureAlgorithm(Phar::SHA1);
+
+copy($fname2, $fname3);
+$p = new Phar($fname3);
+var_dump($p->getSignature());
+
+try {
+$p->setSignatureAlgorithm(Phar::SHA256);
+copy($fname3, $fname4);
+$p = new Phar($fname4);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$p->setSignatureAlgorithm(Phar::SHA512);
+copy($fname4, $fname5);
+$p = new Phar($fname5);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+try {
+$keys=openssl_pkey_new();
+openssl_pkey_export($keys, $privkey);
+$pubkey=openssl_pkey_get_details($keys);
+$p->setSignatureAlgorithm(Phar::OPENSSL, $privkey);
+
+copy($fname5, $fname6);
+file_put_contents($fname6 . '.pubkey', $pubkey['key']);
+$p = new Phar($fname6);
+var_dump($p->getSignature());
+} catch (Exception $e) {
+echo $e->getMessage();
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.4.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.5.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip.pubkey');
+?>
+--EXPECTF--
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(3) "MD5"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(5) "SHA-1"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-256"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "SHA-512"
+}
+array(2) {
+ ["hash"]=>
+ string(%d) "%s"
+ ["hash_type"]=>
+ string(7) "OpenSSL"
+}
+===DONE===
diff --git a/ext/phar/util.c b/ext/phar/util.c
index cb00cbc69..e65f76061 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: util.c,v 1.55.2.42 2009/04/29 03:24:27 cellog Exp $ */
+/* $Id: util.c 284729 2009-07-24 23:53:24Z cellog $ */
#include "phar_internal.h"
#ifdef PHAR_HASH_OK
@@ -1551,6 +1551,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
PHAR_STR(key, str_key);
if ((int)keylen >= path_len || strncmp(str_key, path, keylen)) {
+ PHAR_STR_FREE(str_key);
continue;
} else {
char *test;
@@ -1561,6 +1562,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
if (error) {
spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", str_key);
}
+ PHAR_STR_FREE(str_key);
return NULL;
}
@@ -1568,8 +1570,10 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
if (error) {
spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", str_key);
}
+ PHAR_STR_FREE(str_key);
return NULL;
}
+ PHAR_STR_FREE(str_key);
test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + keylen);
@@ -1661,10 +1665,19 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
Z_TYPE_P(zdata) = IS_STRING;
Z_STRLEN_P(zdata) = end;
+#if PHP_MAJOR_VERSION > 5
+ if (end != (off_t) php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
+#else
if (end != (off_t) php_stream_copy_to_mem(fp, &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
+#endif
zval_dtor(zdata);
zval_dtor(zsig);
zval_dtor(zkey);
+ zval_dtor(openssl);
+ efree(openssl);
+ efree(zdata);
+ efree(zkey);
+ efree(zsig);
return FAILURE;
}
@@ -1678,6 +1691,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
zval_dtor(zkey);
zval_dtor(openssl);
efree(openssl);
+ efree(zdata);
+ efree(zkey);
+ efree(zsig);
return FAILURE;
}
@@ -1796,7 +1812,14 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL);
efree(pfile);
+#if PHP_MAJOR_VERSION > 5
+ if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, (void **) &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
+#else
if (!pfp || !(pubkey_len = php_stream_copy_to_mem(pfp, &pubkey, PHP_STREAM_COPY_ALL, 0)) || !pubkey) {
+#endif
+ if (pfp) {
+ php_stream_close(pfp);
+ }
if (error) {
spprintf(error, 0, "openssl public key could not be read");
}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index ee365d0d1..383561ab8 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -172,6 +172,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
phar_archive_data *mydata = NULL;
phar_entry_info entry = {0};
char *p = buf, *ext, *actual_alias = NULL;
+ char *metadata = NULL;
size = php_stream_tell(fp);
@@ -222,7 +223,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
/* read in archive comment, if any */
if (PHAR_GET_16(locator.comment_len)) {
- char *metadata;
metadata = p + sizeof(locator);
@@ -299,6 +299,30 @@ foundit:
entry.is_zip = 1;
entry.fp_type = PHAR_FP;
entry.is_persistent = mydata->is_persistent;
+#define PHAR_ZIP_FAIL_FREE(errmsg, save) \
+ zend_hash_destroy(&mydata->manifest); \
+ mydata->manifest.arBuckets = 0; \
+ zend_hash_destroy(&mydata->mounted_dirs); \
+ mydata->mounted_dirs.arBuckets = 0; \
+ zend_hash_destroy(&mydata->virtual_dirs); \
+ mydata->virtual_dirs.arBuckets = 0; \
+ php_stream_close(fp); \
+ if (mydata->metadata) { \
+ zval_dtor(mydata->metadata); \
+ } \
+ if (mydata->signature) { \
+ efree(mydata->signature); \
+ } \
+ if (error) { \
+ spprintf(error, 4096, "phar error: %s in zip-based phar \"%s\"", errmsg, mydata->fname); \
+ } \
+ pefree(mydata->fname, mydata->is_persistent); \
+ if (mydata->alias) { \
+ pefree(mydata->alias, mydata->is_persistent); \
+ } \
+ pefree(mydata, mydata->is_persistent); \
+ efree(save); \
+ return FAILURE;
#define PHAR_ZIP_FAIL(errmsg) \
zend_hash_destroy(&mydata->manifest); \
mydata->manifest.arBuckets = 0; \
@@ -310,6 +334,9 @@ foundit:
if (mydata->metadata) { \
zval_dtor(mydata->metadata); \
} \
+ if (mydata->signature) { \
+ efree(mydata->signature); \
+ } \
if (error) { \
spprintf(error, 4096, "phar error: %s in zip-based phar \"%s\"", errmsg, mydata->fname); \
} \
@@ -323,6 +350,7 @@ foundit:
/* add each central directory item to the manifest */
for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
phar_zip_central_dir_file zipentry;
+ off_t beforeus = php_stream_tell(fp);
if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
@@ -374,6 +402,58 @@ foundit:
entry.is_dir = 0;
}
+ if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
+ size_t read;
+ php_stream *sigfile;
+ off_t now;
+ char *sig;
+
+ now = php_stream_tell(fp);
+ pefree(entry.filename, entry.is_persistent);
+ sigfile = php_stream_fopen_tmpfile();
+
+ php_stream_seek(fp, 0, SEEK_SET);
+ /* copy file contents + local headers and zip comment, if any, to be hashed for signature */
+ phar_stream_copy_to_stream(fp, sigfile, entry.header_offset, NULL);
+ /* seek to central directory */
+ php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET);
+ /* copy central directory header */
+ phar_stream_copy_to_stream(fp, sigfile, beforeus - PHAR_GET_32(locator.cdir_offset), NULL);
+ if (metadata) {
+ php_stream_write(sigfile, metadata, PHAR_GET_16(locator.comment_len));
+ }
+ php_stream_seek(fp, sizeof(phar_zip_file_header) + entry.header_offset + entry.filename_len + PHAR_GET_16(zipentry.extra_len), SEEK_SET);
+ sig = (char *) emalloc(entry.uncompressed_filesize);
+ read = php_stream_read(fp, sig, entry.uncompressed_filesize);
+ if (read != entry.uncompressed_filesize) {
+ php_stream_close(sigfile);
+ efree(sig);
+ PHAR_ZIP_FAIL("signature cannot be read");
+ }
+ mydata->sig_flags = PHAR_GET_32(sig);
+ if (FAILURE == phar_verify_signature(sigfile, php_stream_tell(sigfile), mydata->sig_flags, sig + 8, entry.uncompressed_filesize - 8, fname, &mydata->signature, &mydata->sig_len, error TSRMLS_CC)) {
+ efree(sig);
+ if (error) {
+ char *save;
+ php_stream_close(sigfile);
+ spprintf(&save, 4096, "signature cannot be verified: %s", *error);
+ efree(*error);
+ PHAR_ZIP_FAIL_FREE(save, save);
+ } else {
+ php_stream_close(sigfile);
+ PHAR_ZIP_FAIL("signature cannot be verified");
+ }
+ }
+ php_stream_close(sigfile);
+ efree(sig);
+ /* signature checked out, let's ensure this is the last file in the phar */
+ if (i != PHAR_GET_16(locator.count) - 1) {
+ PHAR_ZIP_FAIL("entries exist after signature, invalid phar");
+ }
+
+ continue;
+ }
+
phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
if (PHAR_GET_16(zipentry.extra_len)) {
@@ -520,7 +600,11 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
+#if PHP_MAJOR_VERSION >= 6
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#endif
pefree(entry.filename, entry.is_persistent);
#if PHP_VERSION_ID < 50207
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
@@ -541,7 +625,11 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
+#if PHP_MAJOR_VERSION >= 6
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#endif
pefree(entry.filename, entry.is_persistent);
#if PHP_VERSION_ID < 50207
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
@@ -552,7 +640,11 @@ foundit:
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
} else {
+#if PHP_MAJOR_VERSION >= 6
+ if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
+#endif
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
@@ -1000,6 +1092,76 @@ continue_dir:
}
/* }}} */
+static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pass *pass,
+ smart_str *metadata TSRMLS_DC) /* {{{ */
+{
+ /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
+ if (!phar->is_data || phar->sig_flags) {
+ int signature_length;
+ char *signature, sigbuf[8];
+ phar_entry_info entry = {0};
+ php_stream *newfile;
+ off_t tell, st;
+
+ newfile = php_stream_fopen_tmpfile();
+ st = tell = php_stream_tell(pass->filefp);
+ /* copy the local files, central directory, and the zip comment to generate the hash */
+ php_stream_seek(pass->filefp, 0, SEEK_SET);
+ phar_stream_copy_to_stream(pass->filefp, newfile, tell, NULL);
+ tell = php_stream_tell(pass->centralfp);
+ php_stream_seek(pass->centralfp, 0, SEEK_SET);
+ phar_stream_copy_to_stream(pass->centralfp, newfile, tell, NULL);
+ if (metadata->c) {
+ php_stream_write(newfile, metadata->c, metadata->len);
+ }
+
+ if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error TSRMLS_CC)) {
+ if (pass->error) {
+ char *save = *(pass->error);
+ spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar: %s", save);
+ efree(save);
+ }
+
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+
+ entry.filename = ".phar/signature.bin";
+ entry.filename_len = sizeof(".phar/signature.bin")-1;
+ entry.fp = php_stream_fopen_tmpfile();
+ entry.fp_type = PHAR_MOD;
+ entry.is_modified = 1;
+
+ PHAR_SET_32(sigbuf, phar->sig_flags);
+ PHAR_SET_32(sigbuf + 4, signature_length);
+
+ if (8 != (int)php_stream_write(entry.fp, sigbuf, 8) || signature_length != (int)php_stream_write(entry.fp, signature, signature_length)) {
+ efree(signature);
+ if (pass->error) {
+ spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar %s", phar->fname);
+ }
+
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+
+ efree(signature);
+ entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8;
+ entry.phar = phar;
+ /* throw out return value and write the signature */
+ phar_zip_changed_apply((void *)&entry, (void *)pass TSRMLS_CC);
+ php_stream_close(newfile);
+
+ if (pass->error && *(pass->error)) {
+ /* error is set by writeheaders */
+ php_stream_close(newfile);
+ return FAILURE;
+ }
+ } /* signature */
+ return SUCCESS;
+}
+/* }}} */
+
int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
{
char *pos;
@@ -1084,7 +1246,11 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
user_stub = 0;
+#if PHP_MAJOR_VERSION >= 6
+ if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
+#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
+#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}
@@ -1214,10 +1380,24 @@ fperror:
memset(&eocd, 0, sizeof(eocd));
strncpy(eocd.signature, "PK\5\6", 4);
- PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest));
- PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest));
+ if (!phar->is_data && !phar->sig_flags) {
+ phar->sig_flags = PHAR_SIG_SHA1;
+ }
+ if (phar->sig_flags) {
+ PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest) + 1);
+ PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest) + 1);
+ } else {
+ PHAR_SET_16(eocd.counthere, zend_hash_num_elements(&phar->manifest));
+ PHAR_SET_16(eocd.count, zend_hash_num_elements(&phar->manifest));
+ }
zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass TSRMLS_CC);
+ if (phar->metadata) {
+ /* set phar metadata */
+ PHP_VAR_SERIALIZE_INIT(metadata_hash);
+ php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
+ PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
+ }
if (temperr) {
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
@@ -1226,6 +1406,9 @@ fperror:
temperror:
php_stream_close(pass.centralfp);
nocentralerror:
+ if (phar->metadata) {
+ smart_str_free(&main_metadata_str);
+ }
php_stream_close(pass.filefp);
if (closeoldfile) {
php_stream_close(oldfile);
@@ -1233,6 +1416,10 @@ nocentralerror:
return EOF;
}
+ if (FAILURE == phar_zip_applysignature(phar, &pass, &main_metadata_str TSRMLS_CC)) {
+ goto temperror;
+ }
+
/* save zip */
cdir_size = php_stream_tell(pass.centralfp);
cdir_offset = php_stream_tell(pass.filefp);
@@ -1255,9 +1442,6 @@ nocentralerror:
if (phar->metadata) {
/* set phar metadata */
- PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&main_metadata_str, &phar->metadata, &metadata_hash TSRMLS_CC);
- PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
PHAR_SET_16(eocd.comment_len, main_metadata_str.len);
if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {