]> granicus.if.org Git - php/commitdiff
fix #41773 (php_strip_whitespace sends headers with errors suppressed)
authorAntony Dovgal <tony2001@php.net>
Mon, 25 Jun 2007 21:12:47 +0000 (21:12 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 25 Jun 2007 21:12:47 +0000 (21:12 +0000)
MFB is not needed, output buffering in HEAD handles this situation correctly

NEWS
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index 98f01741a53786613e215ffb5c360509ccb6357f..a8496037aea0002f924924c20e80e46365fb94be 100644 (file)
--- 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)
index d81c0868a3891be17f0ff7babbbf637a16973064..fe672d0fa541cc94b83f2a0b7aa82eaf49cc7f93 100644 (file)
@@ -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);