cvs: php-src(PHP_5_2) /ext/zip php_zip.c /ext/zip/tests bug40228.phpt bug40228.zip
| From: | Pierre-Alain Joye | Date: | Mon, 29 Jan 2007 15:25:06 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/zip php_zip.c /ext/zip/tests bug40228.phpt bug40228.zip | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-42900@lists.php.net to get a copy of this message | ||
pajoye Mon Jan 29 15:25:06 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/zip/tests bug40228.phpt bug40228.zip
Modified files:
/php-src/ext/zip php_zip.c
Log:
- #40228, ZipArchive::extractTo does create empty directories
recursively
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.26&r2=1.1.2.27&diff_format=u
Index: php-src/ext/zip/php_zip.c
diff -u php-src/ext/zip/php_zip.c:1.1.2.26 php-src/ext/zip/php_zip.c:1.1.2.27
--- php-src/ext/zip/php_zip.c:1.1.2.26 Sun Jan 7 03:12:14 2007
+++ php-src/ext/zip/php_zip.c Mon Jan 29 15:25:06 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_zip.c,v 1.1.2.26 2007/01/07 03:12:14 iliaa Exp $ */
+/* $Id: php_zip.c,v 1.1.2.27 2007/01/29 15:25:06 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -106,27 +106,32 @@
char *file_basename;
size_t file_basename_len;
+ int is_dir_only = 0;
if (file_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb)) {
return 0;
}
- memcpy(file_dirname, file, file_len);
-
- dir_len = php_dirname(file_dirname, file_len);
-
- if (dir_len > 0) {
- len = spprintf(&file_dirname_fullpath, 0, "%s/%s", dest, file_dirname);
+ if (file_len > 1 && file[file_len - 1] == '/') {
+ len = spprintf(&file_dirname_fullpath, 0, "%s/%s", dest, file);
+ is_dir_only = 1;
} else {
- len = spprintf(&file_dirname_fullpath, 0, "%s", dest);
- }
+ memcpy(file_dirname, file, file_len);
+ dir_len = php_dirname(file_dirname, file_len);
- php_basename(file, file_len, NULL, 0, &file_basename, &file_basename_len TSRMLS_CC);
+ if (dir_len > 0) {
+ len = spprintf(&file_dirname_fullpath, 0, "%s/%s", dest, file_dirname);
+ } else {
+ len = spprintf(&file_dirname_fullpath, 0, "%s", dest);
+ }
- if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) {
- efree(file_dirname_fullpath);
- efree(file_basename);
- return 0;
+ php_basename(file, file_len, NULL, 0, &file_basename, (unsigned int *)&file_basename_len
TSRMLS_CC);
+
+ if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) {
+ efree(file_dirname_fullpath);
+ efree(file_basename);
+ return 0;
+ }
}
/* let see if the path already exists */
@@ -142,7 +147,9 @@
/* it is a standalone directory, job done */
if (file[file_len - 1] == '/') {
efree(file_dirname_fullpath);
- efree(file_basename);
+ if (!is_dir_only) {
+ efree(file_basename);
+ }
return 1;
}
@@ -2009,7 +2016,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "Zip", "enabled");
- php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.26
2007/01/07 03:12:14 iliaa Exp $");
+ php_info_print_table_row(2, "Extension Version","$Id: php_zip.c,v 1.1.2.27
2007/01/29 15:25:06 pajoye Exp $");
php_info_print_table_row(2, "Zip version", "2.0.0");
php_info_print_table_row(2, "Libzip version", "0.7.1");
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug40228.phpt?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug40228.phpt
+++ php-src/ext/zip/tests/bug40228.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug40228.zip?view=markup&rev=1.1
Index: php-src/ext/zip/tests/bug40228.zip
+++ php-src/ext/zip/tests/bug40228.zip