aboutsummaryrefslogtreecommitdiffstats
path: root/community/php8/content-encoding.patch
blob: 313985faf35560975ea8a3489329f8c933c2d408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 792012885d1926ffc96bed3280e7e9560a54a9ad Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Tue, 12 Apr 2022 17:18:00 +0200
Subject: [PATCH] Fix GH-8218: ob_end_clean does not reset Content-Encoding
 header

Patch-source: https://github.com/php/php-src/pull/8353

The fix for GH-7953 introduced a regression by being to deliberate
adding the respective headers.  These must only be added, if the
handler starts, but is not finalizing.
---
 ext/iconv/iconv.c | 2 +-
 ext/zlib/zlib.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 7a66c965e3cb..f23aa90f52db 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) || (output_context->op & PHP_OUTPUT_HANDLER_START))) {
+		if (mimetype != NULL && (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || ((output_context->op & PHP_OUTPUT_HANDLER_START) && !(output_context->op & PHP_OUTPUT_HANDLER_FINAL)))) {
 			size_t len;
 			char *p = strstr(get_output_encoding(), "//");
 
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index f7cf0d5dac76..774a31e18cd4 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) || (output_context->op & PHP_OUTPUT_HANDLER_START)) {
+	if (!(output_context->op & PHP_OUTPUT_HANDLER_CLEAN) || ((output_context->op & PHP_OUTPUT_HANDLER_START) && !(output_context->op & PHP_OUTPUT_HANDLER_FINAL))) {
 		int flags;
 
 		if (SUCCESS == php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS, &flags)) {