From 5daef5cd4adbd92b514d753a832114076ddc51d4 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 25 Jun 2007 21:12:47 +0000 Subject: [PATCH] fix #41773 (php_strip_whitespace sends headers with errors suppressed) MFB is not needed, output buffering in HEAD handles this situation correctly --- NEWS | 4 +++- ext/standard/basic_functions.c | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 98f01741a5..a8496037ae 100644 --- a/NEWS +++ b/NEWS @@ -36,7 +36,9 @@ PHP NEWS - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory already exists). (Pierre) -- Fixed bug #41765 (Recode crashes/does not work on amd64) +- Fixed bug #41773 (php_strip_whitespace() sends headers with errors + suppressed). (Tony) +- Fixed bug #41765 (Recode crashes/does not work on amd64). (nexus at smoula dot net, Stas) - Fixed bug #41724 (libxml_get_last_error() - errors service request scope). (thekid at php dot net, Ilia) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d81c0868a3..fe672d0fa5 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5455,7 +5455,18 @@ PHP_FUNCTION(highlight_file) if (highlight_file(filename, &syntax_highlighter_ini TSRMLS_CC) == FAILURE) { if (i) { - php_end_ob_buffer (1, 0 TSRMLS_CC); + int res = php_ob_get_buffer(return_value TSRMLS_CC); + + /* flush the buffer only if there is something to flush */ + if (res == SUCCESS && Z_STRLEN_P(return_value) > 0) { + php_end_ob_buffer (1, 0 TSRMLS_CC); + zval_dtor(return_value); + } else { + php_end_ob_buffer (0, 0 TSRMLS_CC); + if (res == SUCCESS) { + zval_dtor(return_value); + } + } } RETURN_FALSE; } @@ -5482,8 +5493,6 @@ PHP_FUNCTION(php_strip_whitespace) RETURN_FALSE; } - php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); - file_handle.type = ZEND_HANDLE_FILENAME; file_handle.filename = filename; file_handle.free_filename = 0; @@ -5491,10 +5500,11 @@ PHP_FUNCTION(php_strip_whitespace) zend_save_lexical_state(&original_lex_state TSRMLS_CC); if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) { zend_restore_lexical_state(&original_lex_state TSRMLS_CC); - php_end_ob_buffer(1, 0 TSRMLS_CC); RETURN_EMPTY_STRING(); } + php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); + zend_strip(TSRMLS_C); zend_destroy_file_handle(&file_handle TSRMLS_CC); -- 2.40.0