File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ PHP NEWS
7878 PROCESS_INFORMATION, an indeterminate comspec pointer after a failed
7979 lookup, and an unchecked CreateFileA() failure. (Ilia Alshanetsky)
8080
81+ - Zlib:
82+ . Fixed inflate_init() dropping the preset dictionary for raw streams with
83+ a non-default window. (Ilia Alshanetsky)
84+
8185
828610 Sep 2026, PHP 8.6.0beta3
8387
Original file line number Diff line number Diff line change 1+ --TEST--
2+ inflate_init(): preset dictionary is honored for raw encoding with a non-default window
3+ --EXTENSIONS--
4+ zlib
5+ --FILE--
6+ <?php
7+ $ dict = "the quick brown fox jumps over the lazy dog " ;
8+ $ data = str_repeat ($ dict . " " , 8 );
9+ $ opts = ['window ' => 10 , 'dictionary ' => $ dict ];
10+
11+ $ def = deflate_init (ZLIB_ENCODING_RAW , $ opts );
12+ $ comp = deflate_add ($ def , $ data , ZLIB_FINISH );
13+
14+ $ inf = inflate_init (ZLIB_ENCODING_RAW , $ opts );
15+ $ out = inflate_add ($ inf , $ comp , ZLIB_FINISH );
16+
17+ var_dump ($ out === $ data );
18+ ?>
19+ --EXPECT--
20+ bool(true)
Original file line number Diff line number Diff line change @@ -943,6 +943,7 @@ PHP_FUNCTION(inflate_init)
943943 ctx -> inflateDictlen = dictlen ;
944944 ctx -> status = Z_OK ;
945945
946+ zend_long orig_encoding = encoding ;
946947 if (encoding < 0 ) {
947948 encoding += 15 - window ;
948949 } else {
@@ -956,7 +957,7 @@ PHP_FUNCTION(inflate_init)
956957 RETURN_FALSE ;
957958 }
958959
959- if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0 ) {
960+ if (orig_encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0 ) {
960961 switch (inflateSetDictionary (& ctx -> Z , (Bytef * ) ctx -> inflateDict , ctx -> inflateDictlen )) {
961962 case Z_OK :
962963 efree (ctx -> inflateDict );
You can’t perform that action at this time.
0 commit comments