24
24
#include "ext/standard/head.h"
25
25
#include "ext/standard/basic_functions.h"
26
26
#include "ext/standard/url_scanner_ex.h"
27
+ #ifdef HAVE_ZLIB
28
+ #include "ext/zlib/php_zlib.h"
29
+ #endif
27
30
#include "SAPI.h"
28
31
29
32
#define OB_DEFAULT_HANDLER_NAME "default output handler"
@@ -405,6 +408,11 @@ PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
405
408
static int php_ob_init_named (uint initial_size , uint block_size , char * handler_name , zval * output_handler , uint chunk_size , zend_bool erase TSRMLS_DC )
406
409
{
407
410
if (OG (ob_nesting_level )> 0 ) {
411
+ #ifdef HAVE_ZLIB
412
+ if (!strncmp (handler_name , "ob_gzhandler" , sizeof ("ob_gzhandler" )) && php_ob_gzhandler_check (TSRMLS_CC )) {
413
+ return FAILURE ;
414
+ }
415
+ #endif
408
416
if (OG (ob_nesting_level )== 1 ) { /* initialize stack */
409
417
zend_stack_init (& OG (ob_buffers ));
410
418
}
@@ -420,7 +428,7 @@ static int php_ob_init_named(uint initial_size, uint block_size, char *handler_n
420
428
OG (active_ob_buffer ).status = 0 ;
421
429
OG (active_ob_buffer ).internal_output_handler = NULL ;
422
430
OG (active_ob_buffer ).handler_name = estrdup (handler_name && handler_name [0 ]?handler_name :OB_DEFAULT_HANDLER_NAME );
423
- OG (active_ob_buffer ).erase = erase ;
431
+ OG (active_ob_buffer ).erase = erase ;
424
432
OG (php_body_write ) = php_b_body_write ;
425
433
return SUCCESS ;
426
434
}
@@ -445,38 +453,33 @@ static zval* php_ob_handler_from_string(const char *handler_name TSRMLS_DC)
445
453
*/
446
454
static int php_ob_init (uint initial_size , uint block_size , zval * output_handler , uint chunk_size , zend_bool erase TSRMLS_DC )
447
455
{
448
- int res , result , len ;
456
+ int result , len ;
449
457
char * handler_name , * next_handler_name ;
450
458
HashPosition pos ;
451
459
zval * * tmp ;
452
460
zval * handler_zval ;
453
461
454
462
if (output_handler && output_handler -> type == IS_STRING ) {
455
- result = 0 ;
456
463
handler_name = Z_STRVAL_P (output_handler );
457
464
while ((next_handler_name = strchr (handler_name , ',' )) != NULL ) {
458
465
len = next_handler_name - handler_name ;
459
466
next_handler_name = estrndup (handler_name , len );
460
467
handler_zval = php_ob_handler_from_string (next_handler_name TSRMLS_CC );
461
- res = php_ob_init_named (initial_size , block_size , next_handler_name , handler_zval , chunk_size , erase TSRMLS_CC );
462
- result &= res ;
463
- if (!res == SUCCESS ) {
468
+ result = php_ob_init_named (initial_size , block_size , next_handler_name , handler_zval , chunk_size , erase TSRMLS_CC );
469
+ if (result != SUCCESS ) {
464
470
zval_dtor (handler_zval );
465
471
FREE_ZVAL (handler_zval );
466
472
}
467
473
handler_name += len + 1 ;
468
474
efree (next_handler_name );
469
475
}
470
476
handler_zval = php_ob_handler_from_string (handler_name TSRMLS_CC );
471
- res = php_ob_init_named (initial_size , block_size , handler_name , handler_zval , chunk_size , erase TSRMLS_CC );
472
- result &= res ;
473
- if (!res == SUCCESS ) {
477
+ result = php_ob_init_named (initial_size , block_size , handler_name , handler_zval , chunk_size , erase TSRMLS_CC );
478
+ if (result != SUCCESS ) {
474
479
zval_dtor (handler_zval );
475
480
FREE_ZVAL (handler_zval );
476
481
}
477
- result = result ? SUCCESS : FAILURE ;
478
482
} else if (output_handler && output_handler -> type == IS_ARRAY ) {
479
- result = 0 ;
480
483
/* do we have array(object,method) */
481
484
if (zend_is_callable (output_handler , 1 , & handler_name )) {
482
485
SEPARATE_ZVAL (& output_handler );
@@ -487,11 +490,10 @@ static int php_ob_init(uint initial_size, uint block_size, zval *output_handler,
487
490
/* init all array elements recursively */
488
491
zend_hash_internal_pointer_reset_ex (Z_ARRVAL_P (output_handler ), & pos );
489
492
while (zend_hash_get_current_data_ex (Z_ARRVAL_P (output_handler ), (void * * )& tmp , & pos ) == SUCCESS ) {
490
- result & = php_ob_init (initial_size , block_size , * tmp , chunk_size , erase TSRMLS_CC );
493
+ result = php_ob_init (initial_size , block_size , * tmp , chunk_size , erase TSRMLS_CC );
491
494
zend_hash_move_forward_ex (Z_ARRVAL_P (output_handler ), & pos );
492
495
}
493
496
}
494
- result = result ? SUCCESS : FAILURE ;
495
497
} else if (output_handler && output_handler -> type == IS_OBJECT ) {
496
498
php_error_docref (NULL TSRMLS_CC , E_ERROR , "No method name given: use ob_start(array($object,'method')) to specify instance $object and the name of a method of class %s to use as output handler" , Z_OBJCE_P (output_handler )-> name );
497
499
result = FAILURE ;
0 commit comments