diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2002-12-30 19:39:31 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2002-12-30 19:39:31 +0000 |
| commit | 0acb52fc3b8807d957165e2dd84f8af7cdcd826c (patch) | |
| tree | 4a4fe045e701cc7cd369a2e42f782ec194ccf9b5 /ext | |
| parent | 67f0a6f6c0f86f122f49264307e6f8ed54e3d93c (diff) | |
| download | php-git-0acb52fc3b8807d957165e2dd84f8af7cdcd826c.tar.gz | |
Fixed bug #21228 (broken check for ob_gzhandler).
Fixed a bug that made ob_start return incorrect return value.
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/zlib/php_zlib.h | 1 | ||||
| -rw-r--r-- | ext/zlib/zlib.c | 46 |
2 files changed, 29 insertions, 18 deletions
diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index 5366337986..65e45fac30 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -54,6 +54,7 @@ PHP_FUNCTION(gzencode); PHP_FUNCTION(ob_gzhandler); int php_enable_output_compression(int buffer_size TSRMLS_DC); +int php_ob_gzhandler_check(TSRMLS_DC); php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); extern php_stream_ops php_stream_gzio_ops; diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 136bd5a268..fe2b4be374 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -890,6 +890,34 @@ PHP_FUNCTION(gzencode) } /* }}} */ +/* {{{ php_ob_gzhandler_check + */ +int php_ob_gzhandler_check(TSRMLS_DC) +{ + /* check for wrong usages */ + if (OG(ob_nesting_level>0)) { + if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used twice"); + return FAILURE; + } + if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'"); + return FAILURE; + } + if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) { + php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'"); + return FAILURE; + } + if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" TSRMLS_CC)) { + return FAILURE; + } + } + + return SUCCESS; +} + +/* }}} */ + /* {{{ proto string ob_gzhandler(string str, int mode) Encode str based on accept-encoding setting - designed to be called from ob_start() */ PHP_FUNCTION(ob_gzhandler) @@ -904,24 +932,6 @@ PHP_FUNCTION(ob_gzhandler) ZEND_WRONG_PARAM_COUNT(); } - /* check for wrong usages */ - if (OG(ob_nesting_level>1)) { - if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used twice"); - RETURN_FALSE; - } - if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'"); - RETURN_FALSE; - } - if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) { - php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'"); - RETURN_FALSE; - } - if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" TSRMLS_CC)) - RETURN_FALSE; - } - if (ZLIBG(ob_gzhandler_status)==-1 || zend_hash_find(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), (void **) &data)==FAILURE || Z_TYPE_PP(data)!=IS_ARRAY |
