diff --git a/NEWS b/NEWS index ba1164f2e21..941be6c0a84 100644 --- a/NEWS +++ b/NEWS @@ -73,6 +73,9 @@ PHP NEWS . Added X509_PURPOSE_OCSP_HELPER and X509_PURPOSE_TIMESTAMP_SIGN constants. (Vincent Jardin) +- Output: + . Clear output handler status flags during handler initialization. (haszi) + - PDO: . Fixed setAttribute and getAttribute. (SakiTakamachi) . Implemented PDO driver-specific subclasses RFC. (danack, kocsismate) diff --git a/UPGRADING b/UPGRADING index 24f4e5f0ecc..4b2e14fb5ae 100644 --- a/UPGRADING +++ b/UPGRADING @@ -313,6 +313,10 @@ PHP 8.4 UPGRADE NOTES . New serial_hex parameter added to openssl_csr_sign to allow setting serial number in the hexadecimal format. +- Output: + . Output handler status flags passed to the flags parameter of ob_start + are now cleared. + - PDO: . getAttribute, enabled to get the value of ATTR_STRINGIFY_FETCHES. diff --git a/main/output.c b/main/output.c index 76d4e7709e8..2c2c13b672a 100644 --- a/main/output.c +++ b/main/output.c @@ -478,7 +478,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, default: user = ecalloc(1, sizeof(php_output_handler_user_func_t)); if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &handler_name, &error)) { - handler = php_output_handler_init(handler_name, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER); + handler = php_output_handler_init(handler_name, chunk_size, PHP_OUTPUT_HANDLER_ABILITY_FLAGS(flags) | PHP_OUTPUT_HANDLER_USER); ZVAL_COPY(&user->zoh, output_handler); handler->func.user = user; } else { @@ -504,7 +504,7 @@ PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, php_output_handler *handler; zend_string *str = zend_string_init(name, name_len, 0); - handler = php_output_handler_init(str, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL); + handler = php_output_handler_init(str, chunk_size, PHP_OUTPUT_HANDLER_ABILITY_FLAGS(flags) | PHP_OUTPUT_HANDLER_INTERNAL); handler->func.internal = output_handler; zend_string_release_ex(str, 0); diff --git a/main/php_output.h b/main/php_output.h index 852aab7fb9d..d722eba953b 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -43,6 +43,8 @@ #define PHP_OUTPUT_HANDLER_DISABLED 0x2000 #define PHP_OUTPUT_HANDLER_PROCESSED 0x4000 +#define PHP_OUTPUT_HANDLER_ABILITY_FLAGS(bitmask) ((bitmask) & ~0xf00f) + /* handler op return values */ typedef enum _php_output_handler_status_t { PHP_OUTPUT_HANDLER_FAILURE, diff --git a/tests/output/ob_start_flags.phpt b/tests/output/ob_start_flags.phpt new file mode 100644 index 00000000000..a52ced6bd10 --- /dev/null +++ b/tests/output/ob_start_flags.phpt @@ -0,0 +1,31 @@ +--TEST-- +ob_start(): Ensure that user supplied handler type and status flags are erased +--FILE-- + $s, + 0, + PHP_OUTPUT_HANDLER_STDFLAGS | + PHP_OUTPUT_HANDLER_TYPE_INTERNAL | + PHP_OUTPUT_HANDLER_STARTED | + PHP_OUTPUT_HANDLER_DISABLED | + PHP_OUTPUT_HANDLER_PROCESSED +); + +$bitmask = ob_get_status()['flags']; + +var_dump($bitmask & PHP_OUTPUT_HANDLER_STDFLAGS); +var_dump($bitmask & PHP_OUTPUT_HANDLER_TYPE_USER); +var_dump($bitmask & PHP_OUTPUT_HANDLER_STARTED); +var_dump($bitmask & PHP_OUTPUT_HANDLER_DISABLED); +var_dump($bitmask & PHP_OUTPUT_HANDLER_PROCESSED); +?> +--EXPECT-- +int(112) +int(1) +int(0) +int(0) +int(0)