|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-11-25 19:02 UTC] witekfl at poczta dot onet dot pl
Description:
------------
The deflate filter doesn't compress all data.
The decompressed data is 1721662 bytes long.
Reproduce code:
---------------
<?php
$f = fopen("http://republika.pl/rkd/data.bz2", "rb");
$data = '';
while (!feof($f)) {
$data .= fread($f, 32768);
}
fclose($f);
$text = bzdecompress($data);
$f3 = fopen("data.html.deflate", "wb");
stream_filter_append($f3, 'zlib.deflate', STREAM_FILTER_WRITE);
fwrite($f3, $text); fclose($f3);
$f5 = fopen("data.html.deflate", "rb");
stream_filter_append($f5, 'zlib.inflate', STREAM_FILTER_READ);
$text_deflate = ''; while (!feof($f5)) { $text_deflate .= fread($f5, 32768); } fclose($f5);
printf("original = %d, deflate = %d\n", strlen($text), strlen($text_deflate));
?>
Expected result:
----------------
original = 1721662, deflate = 1721662
Actual result:
--------------
original = 1721662, deflate = 546816
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 02:00:01 2025 UTC |
This patch solves the problem: --- php-5.2.2/ext/zlib/zlib_filter.c.old 2007-05-07 19:42:29.000000000 +0 200 +++ php-5.2.2/ext/zlib/zlib_filter.c 2007-05-07 21:35:25.000000000 +0200 @@ -100,11 +100,6 @@ consumed += desired; bin += desired; - if (!desired) { - flags |= PSFS_FLAG_FLUSH_CLOSE; - break; - } - if (data->strm.avail_out < data->outbuf_len) { php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm .avail_out; @@ -213,11 +208,6 @@ consumed += desired; bin += desired; - if (!desired) { - flags |= PSFS_FLAG_FLUSH_CLOSE; - break; - } - if (data->strm.avail_out < data->outbuf_len) { php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm .avail_out;