diff options
author | Greg Beaver <cellog@php.net> | 2008-10-11 21:02:53 +0000 |
---|---|---|
committer | Greg Beaver <cellog@php.net> | 2008-10-11 21:02:53 +0000 |
commit | 7a04372a2db137262778dfad7bec3d1aaef5f9ab (patch) | |
tree | 1464aa33eb70e98259b27cd231885f852389af59 /ext/phar | |
parent | 236f646bab2ed160cc2c318f252a7122998e0c3f (diff) | |
download | php-git-7a04372a2db137262778dfad7bec3d1aaef5f9ab.tar.gz |
MFB: work around crap stream filter implementation, update tests for compressed aliases in zip-based phar so they actually test the compression
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/tests/zip/bzip2.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tests/zip/files/bz2_alias.phar.zip | bin | 382 -> 105534 bytes | |||
-rw-r--r-- | ext/phar/tests/zip/files/zlib_alias.phar.zip | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ext/phar/tests/zip/zlib.phpt | 19 | ||||
-rw-r--r-- | ext/phar/zip.c | 13 |
5 files changed, 33 insertions, 1 deletions
diff --git a/ext/phar/tests/zip/bzip2.phpt b/ext/phar/tests/zip/bzip2.phpt index 208f79a47b..a703ce6033 100644 --- a/ext/phar/tests/zip/bzip2.phpt +++ b/ext/phar/tests/zip/bzip2.phpt @@ -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=== diff --git a/ext/phar/tests/zip/files/bz2_alias.phar.zip b/ext/phar/tests/zip/files/bz2_alias.phar.zip Binary files differindex 2bab490a88..8d3082adb8 100644 --- a/ext/phar/tests/zip/files/bz2_alias.phar.zip +++ b/ext/phar/tests/zip/files/bz2_alias.phar.zip diff --git a/ext/phar/tests/zip/files/zlib_alias.phar.zip b/ext/phar/tests/zip/files/zlib_alias.phar.zip Binary files differnew file mode 100644 index 0000000000..d6f98e8916 --- /dev/null +++ b/ext/phar/tests/zip/files/zlib_alias.phar.zip diff --git a/ext/phar/tests/zip/zlib.phpt b/ext/phar/tests/zip/zlib.phpt new file mode 100644 index 0000000000..c7494e2c61 --- /dev/null +++ b/ext/phar/tests/zip/zlib.phpt @@ -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=== diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 221a806f55..c64db266b6 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -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"); } |