Skip to content

Commit d67698a

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-7953: ob_clean() only does not set Content-Encoding
2 parents 341a4de + 8009b21 commit d67698a

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

ext/iconv/iconv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c
311311
mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
312312
}
313313

314-
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
314+
if (mimetype != NULL && (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || (output_context->op & PHP_OUTPUT_HANDLER_START))) {
315315
size_t len;
316316
char *p = strstr(get_output_encoding(), "//");
317317

ext/iconv/tests/gh7953.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
GH-7953 (ob_clean() only may not set Content-* header)
3+
--EXTENSIONS--
4+
iconv
5+
--INI--
6+
input_encoding=UTF-8
7+
output_encoding=ISO-8859-1
8+
--CGI--
9+
--FILE--
10+
<?php
11+
ob_start('ob_iconv_handler');
12+
ob_clean();
13+
14+
echo 'Hello World';
15+
?>
16+
--EXPECTF--
17+
%a
18+
--EXPECTHEADERS--
19+
Content-Type: text/html; charset=ISO-8859-1

ext/zlib/tests/gh7953.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
GH-7953 (ob_clean() only may not set Content-* header)
3+
--EXTENSIONS--
4+
zlib
5+
--CGI--
6+
--ENV--
7+
HTTP_ACCEPT_ENCODING=gzip
8+
--FILE--
9+
<?php
10+
ob_start('ob_gzhandler');
11+
ob_clean();
12+
13+
echo 'Hello World';
14+
?>
15+
--EXPECTF--
16+
%a
17+
--EXPECTHEADERS--
18+
Content-Encoding: gzip
19+
Vary: Accept-Encoding

ext/zlib/zlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o
281281
return FAILURE;
282282
}
283283

284-
if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
284+
if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || (output_context->op & PHP_OUTPUT_HANDLER_START)) {
285285
int flags;
286286

287287
if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags)) {

0 commit comments

Comments
 (0)