]> granicus.if.org Git - php/commitdiff
MFB: work around crap stream filter implementation, update tests for compressed alias...
authorGreg Beaver <cellog@php.net>
Sat, 11 Oct 2008 21:02:53 +0000 (21:02 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 11 Oct 2008 21:02:53 +0000 (21:02 +0000)
ext/phar/tests/zip/bzip2.phpt
ext/phar/tests/zip/files/bz2_alias.phar.zip
ext/phar/tests/zip/files/zlib_alias.phar.zip [new file with mode: 0644]
ext/phar/tests/zip/zlib.phpt [new file with mode: 0644]
ext/phar/zip.c

index 208f79a47b610f206b26822333e79279f6ae57ce..a703ce60338932eb77683ca24f830906f947eee7 100644 (file)
@@ -79,5 +79,5 @@ $a = new corrupt_zipmaker;
 $a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11);
 $a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip');
 ?>
-string(7) "hithere"
+string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
 ===DONE===
index 2bab490a888c4d7e755ececbaeabce448b43a072..8d3082adb8518fcf869389ba3bfeb78e107aafe0 100644 (file)
Binary files a/ext/phar/tests/zip/files/bz2_alias.phar.zip and b/ext/phar/tests/zip/files/bz2_alias.phar.zip differ
diff --git a/ext/phar/tests/zip/files/zlib_alias.phar.zip b/ext/phar/tests/zip/files/zlib_alias.phar.zip
new file mode 100644 (file)
index 0000000..d6f98e8
Binary files /dev/null and b/ext/phar/tests/zip/files/zlib_alias.phar.zip differ
diff --git a/ext/phar/tests/zip/zlib.phpt b/ext/phar/tests/zip/zlib.phpt
new file mode 100644 (file)
index 0000000..c7494e2
--- /dev/null
@@ -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===
index 221a806f559c49004d370df004470130fd8f992d..c64db266b6c8759d254e99b6fb53dad65c9f5869 100644 (file)
@@ -489,6 +489,13 @@ foundit:
                        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 @@ foundit:
 
                                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 @@ foundit:
 
                                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");
                                }