cellog          Sat Oct 11 21:02:53 2008 UTC

  Modified files:              
    /php-src/ext/phar   zip.c 
    /php-src/ext/phar/tests/zip zlib.phpt bzip2.phpt 
    /php-src/ext/phar/tests/zip/files   zlib_alias.phar.zip 
                                        bz2_alias.phar.zip 
  Log:
  MFB: work around crap stream filter implementation, update tests for 
compressed aliases in zip-based phar so they actually test the compression
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/zip.c?r1=1.55&r2=1.56&diff_format=u
Index: php-src/ext/phar/zip.c
diff -u php-src/ext/phar/zip.c:1.55 php-src/ext/phar/zip.c:1.56
--- php-src/ext/phar/zip.c:1.55 Mon Sep 22 01:40:51 2008
+++ php-src/ext/phar/zip.c      Sat Oct 11 21:02:53 2008
@@ -489,6 +489,13 @@
                        fp->writepos = fp->readpos = 0;
 #endif
                        php_stream_seek(fp, entry.offset, SEEK_SET);
+                       /* these next lines should be for php < 5.2.6 after 5.3 
filters are fixed */
+                       fp->writepos = 0;
+                       fp->readpos = 0;
+                       php_stream_seek(fp, entry.offset, SEEK_SET);
+                       fp->writepos = 0;
+                       fp->readpos = 0;
+                       /* the above lines should be for php < 5.2.6 after 5.3 
filters are fixed */
 
                        mydata->alias_len = entry.uncompressed_filesize;
 
@@ -504,6 +511,9 @@
 
                                if (!(entry.uncompressed_filesize = 
php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || 
!actual_alias) {
                                        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)");
+#endif
                                        PHAR_ZIP_FAIL("unable to read in alias, 
truncated");
                                }
 
@@ -522,6 +532,9 @@
 
                                if (!(entry.uncompressed_filesize = 
php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || 
!actual_alias) {
                                        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)");
+#endif
                                        PHAR_ZIP_FAIL("unable to read in alias, 
truncated");
                                }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/zip/zlib.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/phar/tests/zip/zlib.phpt
diff -u /dev/null php-src/ext/phar/tests/zip/zlib.phpt:1.2
--- /dev/null   Sat Oct 11 21:02:53 2008
+++ php-src/ext/phar/tests/zip/zlib.phpt        Sat Oct 11 21:02:53 2008
@@ -0,0 +1,19 @@
+--TEST--
+Phar: process zlib-compressed zip alias
+--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
+try {
+       $a = new Phar(dirname(__FILE__) . '/files/zlib_alias.phar.zip');
+       var_dump($a->getAlias());
+} catch (Exception $e) {
+       echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECT--
+string(175) 
"hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/zip/bzip2.phpt?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/phar/tests/zip/bzip2.phpt
diff -u php-src/ext/phar/tests/zip/bzip2.phpt:1.3 
php-src/ext/phar/tests/zip/bzip2.phpt:1.4
--- php-src/ext/phar/tests/zip/bzip2.phpt:1.3   Sun Sep 14 06:32:52 2008
+++ php-src/ext/phar/tests/zip/bzip2.phpt       Sat Oct 11 21:02:53 2008
@@ -79,5 +79,5 @@
 $a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11);
 $a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip');
 ?>
-string(7) "hithere"
+string(175) 
"hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
 ===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/zip/files/zlib_alias.phar.zip?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/phar/tests/zip/files/zlib_alias.phar.zip
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/zip/files/bz2_alias.phar.zip?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/phar/tests/zip/files/bz2_alias.phar.zip



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to