diff options
Diffstat (limited to 'ext/zip')
-rw-r--r-- | ext/zip/php_zip.c | 23 | ||||
-rw-r--r-- | ext/zip/php_zip.h | 17 | ||||
-rw-r--r-- | ext/zip/tests/bug40228-mb.phpt | 23 | ||||
-rw-r--r-- | ext/zip/tests/bug40228私はガラスを食べられます.zip | bin | 0 -> 274 bytes | |||
-rw-r--r-- | ext/zip/tests/bug64342_1-mb.phpt | 37 | ||||
-rw-r--r-- | ext/zip/zip_stream.c | 5 |
6 files changed, 81 insertions, 24 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 473e231b46..4685fb2486 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -499,7 +499,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v char *result; #endif glob_t globbuf; - int n; + uint n; int ret; if (pattern_len >= MAXPATHLEN) { @@ -589,7 +589,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v globfree(&globbuf); return globbuf.gl_pathc; #else - php_error_docref(NULL, E_ERROR, "Glob support is not available"); + zend_throw_error(NULL, "Glob support is not available"); return 0; #endif /* HAVE_GLOB */ } @@ -1694,7 +1694,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* if (add_path) { if ((add_path_len + file_stripped_len) > MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "Entry name too long (max: %d, %pd given)", + php_error_docref(NULL, E_WARNING, "Entry name too long (max: %d, %zd given)", MAXPATHLEN - 1, (add_path_len + file_stripped_len)); zval_ptr_dtor(return_value); RETURN_FALSE; @@ -3003,7 +3003,7 @@ static const zend_function_entry zip_class_functions[] = { ZIPARCHIVE_ME(getExternalAttributesIndex, arginfo_ziparchive_getextattrindex, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(setCompressionName, arginfo_ziparchive_setcompname, ZEND_ACC_PUBLIC) ZIPARCHIVE_ME(setCompressionIndex, arginfo_ziparchive_setcompindex, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ @@ -3047,7 +3047,6 @@ static PHP_MINIT_FUNCTION(zip) REGISTER_ZIP_CLASS_CONST_LONG("FL_NODIR", ZIP_FL_NODIR); REGISTER_ZIP_CLASS_CONST_LONG("FL_COMPRESSED", ZIP_FL_COMPRESSED); REGISTER_ZIP_CLASS_CONST_LONG("FL_UNCHANGED", ZIP_FL_UNCHANGED); - #ifdef ZIP_FL_ENC_GUESS /* Default filename encoding policy. */ REGISTER_ZIP_CLASS_CONST_LONG("FL_ENC_GUESS", ZIP_FL_ENC_GUESS); @@ -3065,6 +3064,20 @@ static PHP_MINIT_FUNCTION(zip) REGISTER_ZIP_CLASS_CONST_LONG("FL_ENC_CP437", ZIP_FL_ENC_CP437); #endif +/* XXX The below are rather not implemented or to check whether makes sense to expose. */ +/*#ifdef ZIP_FL_RECOMPRESS + REGISTER_ZIP_CLASS_CONST_LONG("FL_RECOMPRESS", ZIP_FL_RECOMPRESS); +#endif +#ifdef ZIP_FL_ENCRYPTED + REGISTER_ZIP_CLASS_CONST_LONG("FL_ENCRYPTED", ZIP_FL_ENCRYPTED); +#endif +#ifdef ZIP_FL_LOCAL + REGISTER_ZIP_CLASS_CONST_LONG("FL_LOCAL", ZIP_FL_LOCAL); +#endif +#ifdef ZIP_FL_CENTRAL + REGISTER_ZIP_CLASS_CONST_LONG("FL_CENTRAL", ZIP_FL_CENTRAL); +#endif */ + REGISTER_ZIP_CLASS_CONST_LONG("CM_DEFAULT", ZIP_CM_DEFAULT); REGISTER_ZIP_CLASS_CONST_LONG("CM_STORE", ZIP_CM_STORE); REGISTER_ZIP_CLASS_CONST_LONG("CM_SHRINK", ZIP_CM_SHRINK); diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index 3bc0cce0f6..ef861a4e7d 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -39,22 +39,7 @@ extern zend_module_entry zip_module_entry; #define PHP_ZIP_VERSION "1.13.5" -#ifndef Z_SET_REFCOUNT_P -# if PHP_MAJOR_VERSION < 6 && (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3) -# define Z_SET_REFCOUNT_P(pz, rc) pz->refcount = rc -# define Z_UNSET_ISREF_P(pz) pz->is_ref = 0 -# endif -#endif - -/* {{{ ZIP_OPENBASEDIR_CHECKPATH(filename) */ -#if PHP_API_VERSION < 20100412 -# define ZIP_OPENBASEDIR_CHECKPATH(filename) \ - (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename) -#else -#define ZIP_OPENBASEDIR_CHECKPATH(filename) \ - php_check_open_basedir(filename) -#endif -/* }}} */ +#define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename) typedef struct _ze_zip_rsrc { struct zip *za; diff --git a/ext/zip/tests/bug40228-mb.phpt b/ext/zip/tests/bug40228-mb.phpt new file mode 100644 index 0000000000..109172d2d5 --- /dev/null +++ b/ext/zip/tests/bug40228-mb.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #40228 (extractTo does not create recursive empty path) +--SKIPIF-- +<?php if (!extension_loaded("zip")) print "skip"; ?> +--FILE-- +<?php +$dest = dirname(__FILE__); +$arc_name = $dest . "/bug40228私はガラスを食べられます.zip"; +$zip = new ZipArchive; +$zip->open($arc_name, ZIPARCHIVE::CREATE);; +$zip->extractTo($dest); +if (is_dir($dest . '/test/empty')) { + echo "Ok\n"; + rmdir($dest . '/test/empty'); + rmdir($dest . '/test'); +} else { + echo "Failed.\n"; +} +echo "Done\n"; +?> +--EXPECT-- +Ok +Done diff --git a/ext/zip/tests/bug40228私はガラスを食べられます.zip b/ext/zip/tests/bug40228私はガラスを食べられます.zip Binary files differnew file mode 100644 index 0000000000..bbcd9515f8 --- /dev/null +++ b/ext/zip/tests/bug40228私はガラスを食べられます.zip diff --git a/ext/zip/tests/bug64342_1-mb.phpt b/ext/zip/tests/bug64342_1-mb.phpt new file mode 100644 index 0000000000..caac92d0f9 --- /dev/null +++ b/ext/zip/tests/bug64342_1-mb.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #64342 ZipArchive::addFile() has to check file existence (variation 2) +--SKIPIF-- +<?php +/* $Id$ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__私はガラスを食べられますtmp_oo_addfile.zip'; + +copy($dirname . 'test.zip', $file); + +$zip = new ZipArchive; +if (!$zip->open($file)) { + exit('failed'); +} +if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) { + echo "failed\n"; +} +if ($zip->status == ZIPARCHIVE::ER_OK) { + dump_entries_name($zip); + $zip->close(); +} else { + echo "failed\n"; +} +@unlink($file); +?> +--EXPECTF-- +failed +0 bar +1 foobar/ +2 foobar/baz +3 entry1.txt diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 244ff4dfa5..dea01529a0 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -21,7 +21,6 @@ #endif #include "php.h" #if HAVE_ZIP -#if defined(ZEND_ENGINE_2) || defined(ZEND_ENGINE_3) #include "php_streams.h" #include "ext/standard/file.h" @@ -348,7 +347,8 @@ static php_stream_wrapper_ops zip_stream_wops = { NULL, /* unlink */ NULL, /* rename */ NULL, /* mkdir */ - NULL /* rmdir */ + NULL, /* rmdir */ + NULL }; php_stream_wrapper php_stream_zip_wrapper = { @@ -356,5 +356,4 @@ php_stream_wrapper php_stream_zip_wrapper = { NULL, 0 /* is_url */ }; -#endif /* defined(ZEND_ENGINE_2) || defined(ZEND_ENGINE_3) */ #endif /* HAVE_ZIP */ |