diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 90c209cbcbf00..d0693c08f2062 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -311,7 +311,7 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; } - if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) { + if (mimetype != NULL && (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || (output_context->op & PHP_OUTPUT_HANDLER_START))) { size_t len; char *p = strstr(get_output_encoding(), "//"); diff --git a/ext/iconv/tests/gh7953.phpt b/ext/iconv/tests/gh7953.phpt new file mode 100644 index 0000000000000..bfc249fb9f21e --- /dev/null +++ b/ext/iconv/tests/gh7953.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-7953 (ob_clean() only may not set Content-* header) +--SKIPIF-- + +--INI-- +input_encoding=UTF-8 +output_encoding=ISO-8859-1 +--CGI-- +--FILE-- + +--EXPECTF-- +%a +--EXPECTHEADERS-- +Content-Type: text/html; charset=ISO-8859-1 diff --git a/ext/zlib/tests/gh7953.phpt b/ext/zlib/tests/gh7953.phpt new file mode 100644 index 0000000000000..d5d9011c03281 --- /dev/null +++ b/ext/zlib/tests/gh7953.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-7953 (ob_clean() only may not set Content-* header) +--SKIPIF-- + +--CGI-- +--ENV-- +HTTP_ACCEPT_ENCODING=gzip +--FILE-- + +--EXPECTF-- +%a +--EXPECTHEADERS-- +Content-Encoding: gzip +Vary: Accept-Encoding diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 75bd273526eb6..f7cf0d5dac76a 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -281,7 +281,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o return FAILURE; } - if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) { + if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || (output_context->op & PHP_OUTPUT_HANDLER_START)) { int flags; if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags)) {