From 714d980db4b86bd1352ab0265ff89710a8afafb0 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 12 Nov 2020 16:47:18 +0100 Subject: [PATCH 1/3] Fix #77594: ob_tidyhandler is never reset --- ext/tidy/tidy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index a1a5184dd5dd2..42c1b30ec6efe 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -1101,6 +1101,7 @@ static PHP_RINIT_FUNCTION(tidy) ZEND_TSRMLS_CACHE_UPDATE(); #endif + TG(clean_output) = 0; php_tidy_clean_output_start(ZEND_STRL("ob_tidyhandler")); return SUCCESS; From bb582141ca416bbe3a930bfa4dd9653b86dcda9b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 13 Nov 2020 11:49:43 +0100 Subject: [PATCH 2/3] Reset to original INI value on request shutdown --- ext/tidy/tidy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 42c1b30ec6efe..5cad767787e9b 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -240,6 +240,7 @@ static int php_tidy_output_handler(void **nothing, php_output_context *output_co static PHP_MINIT_FUNCTION(tidy); static PHP_MSHUTDOWN_FUNCTION(tidy); static PHP_RINIT_FUNCTION(tidy); +static PHP_RSHUTDOWN_FUNCTION(tidy); static PHP_MINFO_FUNCTION(tidy); static PHP_FUNCTION(tidy_getopt); @@ -500,7 +501,7 @@ zend_module_entry tidy_module_entry = { PHP_MINIT(tidy), PHP_MSHUTDOWN(tidy), PHP_RINIT(tidy), - NULL, + PHP_RSHUTDOWN(tidy), PHP_MINFO(tidy), PHP_TIDY_VERSION, PHP_MODULE_GLOBALS(tidy), @@ -1101,12 +1102,16 @@ static PHP_RINIT_FUNCTION(tidy) ZEND_TSRMLS_CACHE_UPDATE(); #endif - TG(clean_output) = 0; php_tidy_clean_output_start(ZEND_STRL("ob_tidyhandler")); return SUCCESS; } +static PHP_RSHUTDOWN_FUNCTION(tidy) +{ + TG(clean_output) = INI_ORIG_BOOL("tidy.clean_output"); +} + static PHP_MSHUTDOWN_FUNCTION(tidy) { UNREGISTER_INI_ENTRIES(); From 50a31bd3090ea959ee58d46aeb750be49ac26489 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 14 Nov 2020 15:03:58 +0100 Subject: [PATCH 3/3] Return SUCCESS from request shutdown handler We also add a test case. --- ext/tidy/tests/bug77594.phpt | 15 +++++++++++++++ ext/tidy/tidy.c | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 ext/tidy/tests/bug77594.phpt diff --git a/ext/tidy/tests/bug77594.phpt b/ext/tidy/tests/bug77594.phpt new file mode 100644 index 0000000000000..0d84a035f795f --- /dev/null +++ b/ext/tidy/tests/bug77594.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #77594 (ob_tidyhandler is never reset) +--DESCRIPTION-- +Test is useful only with --repeat 2 (or more) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 5cad767787e9b..266e6510efbf1 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -1110,6 +1110,8 @@ static PHP_RINIT_FUNCTION(tidy) static PHP_RSHUTDOWN_FUNCTION(tidy) { TG(clean_output) = INI_ORIG_BOOL("tidy.clean_output"); + + return SUCCESS; } static PHP_MSHUTDOWN_FUNCTION(tidy)