cvs: pecl /phar phar.c phar_internal.h /phar/tests 001.phpt 033.phpt phar_test.inc
| From: | Greg Beaver | Date: | Sat, 19 Jan 2008 18:30:29 +0000 |
| Subject: | cvs: pecl /phar phar.c phar_internal.h /phar/tests 001.phpt 033.phpt phar_test.inc | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-9564@lists.php.net to get a copy of this message | ||
cellog Sat Jan 19 18:30:29 2008 UTC
Modified files:
/pecl/phar phar.c phar_internal.h
/pecl/phar/tests 001.phpt 033.phpt phar_test.inc
Log:
bump API version if the created phar has directories in it, so that it won't load with older
phar versions
http://cvs.php.net/viewvc.cgi/pecl/phar/phar.c?r1=1.278&r2=1.279&diff_format=u
Index: pecl/phar/phar.c
diff -u pecl/phar/phar.c:1.278 pecl/phar/phar.c:1.279
--- pecl/phar/phar.c:1.278 Sat Jan 19 04:26:21 2008
+++ pecl/phar/phar.c Sat Jan 19 18:30:28 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.278 2008/01/19 04:26:21 cellog Exp $ */
+/* $Id: phar.c,v 1.279 2008/01/19 18:30:28 cellog Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1331,7 +1331,7 @@
if (buffer + entry.filename_len + 20 > endbuffer) {
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest
entry)");
}
- if (buffer[entry.filename_len - 1] == '/') {
+ if ((manifest_ver & PHAR_API_VER_MASK) >= PHAR_API_MIN_DIR &&
buffer[entry.filename_len - 1] == '/') {
entry.is_dir = 1;
entry.filename_len--;
entry.flags |= PHAR_ENT_PERM_DEF_DIR;
@@ -2380,7 +2380,7 @@
char *newstub;
phar_entry_info *entry, *newentry;
int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
- char *buf, *pos;
+ char *buf, *pos, has_dirs = 0;
char manifest[18], entry_buffer[24];
off_t manifest_ftell;
long offset;
@@ -2561,6 +2561,10 @@
/* after excluding deleted files, calculate manifest size in bytes and number of entries */
++new_manifest_count;
+ if (entry->is_dir) {
+ /* we use this to calculate API version, 1.1.1 is used for phars with directories */
+ has_dirs = 1;
+ }
if (entry->metadata) {
if (entry->metadata_str.c) {
smart_str_free(&entry->metadata_str);
@@ -2701,8 +2705,13 @@
manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len;
phar_set_32(manifest, manifest_len);
phar_set_32(manifest+4, new_manifest_count);
- *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF);
- *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0));
+ if (has_dirs) {
+ *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF);
+ *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0));
+ } else {
+ *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION_NODIR) >> 8) & 0xFF);
+ *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION_NODIR) & 0xF0));
+ }
phar_set_32(manifest+10, global_flags);
phar_set_32(manifest+14, phar->alias_len);
@@ -3321,7 +3330,7 @@
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHAR_EXT_VERSION_STR);
php_info_print_table_row(2, "Phar API version", PHAR_API_VERSION_STR);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.278 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.279 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
#if HAVE_PHAR_ZIP
http://cvs.php.net/viewvc.cgi/pecl/phar/phar_internal.h?r1=1.67&r2=1.68&diff_format=u
Index: pecl/phar/phar_internal.h
diff -u pecl/phar/phar_internal.h:1.67 pecl/phar/phar_internal.h:1.68
--- pecl/phar/phar_internal.h:1.67 Sat Jan 19 04:26:21 2008
+++ pecl/phar/phar_internal.h Sat Jan 19 18:30:28 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.67 2008/01/19 04:26:21 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.68 2008/01/19 18:30:28 cellog Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -80,9 +80,12 @@
#endif
#define PHAR_EXT_VERSION_STR "1.3.0"
-#define PHAR_API_VERSION_STR "1.1.0"
+#define PHAR_API_VERSION_STR "1.1.1"
/* x.y.z maps to 0xyz0 */
-#define PHAR_API_VERSION 0x1100
+#define PHAR_API_VERSION 0x1110
+/* if we bump PHAR_API_VERSION, change this from 0x1100 to PHAR_API_VERSION */
+#define PHAR_API_VERSION_NODIR 0x1100
+#define PHAR_API_MIN_DIR 0x1110
#define PHAR_API_MIN_READ 0x1000
#define PHAR_API_MAJORVERSION 0x1000
#define PHAR_API_MAJORVER_MASK 0xF000
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/001.phpt?r1=1.12&r2=1.13&diff_format=u
Index: pecl/phar/tests/001.phpt
diff -u pecl/phar/tests/001.phpt:1.12 pecl/phar/tests/001.phpt:1.13
--- pecl/phar/tests/001.phpt:1.12 Fri Jan 4 16:26:42 2008
+++ pecl/phar/tests/001.phpt Sat Jan 19 18:30:29 2008
@@ -8,5 +8,5 @@
?>
===DONE===
--EXPECT--
-string(5) "1.1.0"
+string(5) "1.1.1"
===DONE===
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/033.phpt?r1=1.3&r2=1.4&diff_format=u
Index: pecl/phar/tests/033.phpt
diff -u pecl/phar/tests/033.phpt:1.3 pecl/phar/tests/033.phpt:1.4
--- pecl/phar/tests/033.phpt:1.3 Wed Jan 9 00:58:36 2008
+++ pecl/phar/tests/033.phpt Sat Jan 19 18:30:29 2008
@@ -14,6 +14,7 @@
$files = array();
$files['a.php'] = '<?php echo "This is a\n"; include
"'.$pname.'/b.php"; ?>';
$files['dir/'] = '';
+$hasdir = 1;
include 'phar_test.inc';
$a = new Phar($fname);
var_dump($a['a.php']->isExecutable());
http://cvs.php.net/viewvc.cgi/pecl/phar/tests/phar_test.inc?r1=1.13&r2=1.14&diff_format=u
Index: pecl/phar/tests/phar_test.inc
diff -u pecl/phar/tests/phar_test.inc:1.13 pecl/phar/tests/phar_test.inc:1.14
--- pecl/phar/tests/phar_test.inc:1.13 Wed Jan 9 08:48:55 2008
+++ pecl/phar/tests/phar_test.inc Sat Jan 19 18:30:29 2008
@@ -51,7 +51,7 @@
$alias = 'hio';
if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
-$manifest = pack('VnVV', count($files), 0x1000, $gflags, strlen($alias)) . $alias .
pack('V', strlen($pmeta)) . $pmeta . $manifest;
+$manifest = pack('VnVV', count($files), isset($hasdir) ? 0x1110 : 0x1000, $gflags,
strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $manifest;
$file .= pack('V', strlen($manifest)) . $manifest;
foreach($files as $cont)