[php-src] master: Merge branch 'PHP-8.5'
| From: | Ilia Alshanetsky | Date: | Sat, 19 Sep 2026 22:05:34 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141298@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-19T18:02:39-04:00
Commit: https://github.com/php/php-src/commit/64760a1eda4d4eae2cce14245d31e68533fda8fd
Raw diff: https://github.com/php/php-src/commit/64760a1eda4d4eae2cce14245d31e68533fda8fd.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
ext/zlib: honor preset dictionary for raw inflate with non-default window
Changed paths:
A ext/zlib/tests/inflate_raw_dictionary_window.phpt
M NEWS
M ext/zlib/zlib.c
Diff:
diff --git a/NEWS b/NEWS
index 1c02aa9ec650..4dfd11f500f6 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,10 @@ PHP NEWS
PROCESS_INFORMATION, an indeterminate comspec pointer after a failed
lookup, and an unchecked CreateFileA() failure. (Ilia Alshanetsky)
+- Zlib:
+ . Fixed inflate_init() dropping the preset dictionary for raw streams with
+ a non-default window. (Ilia Alshanetsky)
+
10 Sep 2026, PHP 8.6.0beta3
diff --git a/ext/zlib/tests/inflate_raw_dictionary_window.phpt
b/ext/zlib/tests/inflate_raw_dictionary_window.phpt
new file mode 100644
index 000000000000..0269127c1368
--- /dev/null
+++ b/ext/zlib/tests/inflate_raw_dictionary_window.phpt
@@ -0,0 +1,20 @@
+--TEST--
+inflate_init(): preset dictionary is honored for raw encoding with a non-default window
+--EXTENSIONS--
+zlib
+--FILE--
+<?php
+$dict = "the quick brown fox jumps over the lazy dog";
+$data = str_repeat($dict . " ", 8);
+$opts = ['window' => 10, 'dictionary' => $dict];
+
+$def = deflate_init(ZLIB_ENCODING_RAW, $opts);
+$comp = deflate_add($def, $data, ZLIB_FINISH);
+
+$inf = inflate_init(ZLIB_ENCODING_RAW, $opts);
+$out = inflate_add($inf, $comp, ZLIB_FINISH);
+
+var_dump($out === $data);
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index f88350081fe3..61f2e35e9bb6 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -943,6 +943,7 @@ PHP_FUNCTION(inflate_init)
ctx->inflateDictlen = dictlen;
ctx->status = Z_OK;
+ zend_long orig_encoding = encoding;
if (encoding < 0) {
encoding += 15 - window;
} else {
@@ -956,7 +957,7 @@ PHP_FUNCTION(inflate_init)
RETURN_FALSE;
}
- if (encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) {
+ if (orig_encoding == PHP_ZLIB_ENCODING_RAW && dictlen > 0) {
switch (inflateSetDictionary(&ctx->Z, (Bytef *) ctx->inflateDict,
ctx->inflateDictlen)) {
case Z_OK:
efree(ctx->inflateDict);