From: [EMAIL PROTECTED] Operating system: n/a PHP version: 5.2.5 PHP Bug Type: Streams related Bug description: zlib filter is unable to auto-detect gzip/zlib file headers
Description: ------------ according to the zlib documentation for inflateInit2() in zlib.h (online copy at http://www.raspberryginger.com/jbailey/minix/html/zlib_8h-source.html): windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR) zlib.inflate filter's filterparams only accepts window size of 15, but should accept up to 15+32 according to these docs. Reproduce code: --------------- <?php /* $Id: zlib_filter_inflate.phpt,v 1.1.2.1 2005/11/24 04:37:47 pollita Exp $ */ $a = gzopen(dirname(__FILE__) . '/test.txt.gz', 'w'); fwrite($a, "This is quite the thing ain't it\n"); fclose($a); $fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r'); stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ); echo fread($fp, 2000); fclose($fp); echo "1\n"; $fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r'); // zlib format $fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r'); stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16)); echo "2\n"; echo fread($fp, 2000); fclose($fp); // auto-detect $fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r'); stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+32)); echo "3\n"; echo fread($fp, 2000); fclose($fp); ?> Expected result: ---------------- 1 2 This is quite the thing ain't it 3 This is quite the thing ain't it Actual result: -------------- 1 2 3 -- Edit bug report at http://bugs.php.net/?id=43793&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43793&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43793&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43793&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43793&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43793&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43793&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43793&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43793&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43793&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43793&r=support Expected behavior: http://bugs.php.net/fix.php?id=43793&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43793&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43793&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43793&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43793&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43793&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43793&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43793&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43793&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43793&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43793&r=mysqlcfg