mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Fix bug #60768 Output buffer not discarded
in php_output_handler_op(): * if appending to buffer succeeds, just return HANDLER_NO_DATA and do nothing else * if a zero sized string or true is returned from the handler function, reset the context as well as the handler's buffer
This commit is contained in:
parent
36df53421e
commit
f32760bd40
2 changed files with 31 additions and 5 deletions
|
@ -885,7 +885,8 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
|
||||||
|
|
||||||
/* storable? */
|
/* storable? */
|
||||||
if (php_output_handler_append(handler, &context->in TSRMLS_CC) && !context->op) {
|
if (php_output_handler_append(handler, &context->in TSRMLS_CC) && !context->op) {
|
||||||
status = PHP_OUTPUT_HANDLER_NO_DATA;
|
context->op = original_op;
|
||||||
|
return PHP_OUTPUT_HANDLER_NO_DATA;
|
||||||
} else {
|
} else {
|
||||||
/* need to start? */
|
/* need to start? */
|
||||||
if (!(handler->flags & PHP_OUTPUT_HANDLER_STARTED)) {
|
if (!(handler->flags & PHP_OUTPUT_HANDLER_STARTED)) {
|
||||||
|
@ -961,13 +962,13 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
|
||||||
handler->buffer.used = 0;
|
handler->buffer.used = 0;
|
||||||
handler->buffer.size = 0;
|
handler->buffer.size = 0;
|
||||||
break;
|
break;
|
||||||
case PHP_OUTPUT_HANDLER_SUCCESS:
|
|
||||||
/* no more buffered data */
|
|
||||||
handler->buffer.used = 0;
|
|
||||||
break;
|
|
||||||
case PHP_OUTPUT_HANDLER_NO_DATA:
|
case PHP_OUTPUT_HANDLER_NO_DATA:
|
||||||
/* handler ate all */
|
/* handler ate all */
|
||||||
php_output_context_reset(context);
|
php_output_context_reset(context);
|
||||||
|
/* no break */
|
||||||
|
case PHP_OUTPUT_HANDLER_SUCCESS:
|
||||||
|
/* no more buffered data */
|
||||||
|
handler->buffer.used = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
tests/output/bug60768.phpt
Normal file
25
tests/output/bug60768.phpt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #60768 Output buffer not discarded
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
global $storage;
|
||||||
|
|
||||||
|
ob_start(function($buffer) use (&$storage) { $storage .= $buffer; }, 20);
|
||||||
|
|
||||||
|
echo str_repeat("0", 20); // fill in the buffer
|
||||||
|
|
||||||
|
for($i = 0; $i < 10; $i++) {
|
||||||
|
echo str_pad($i, 9, ' ', STR_PAD_LEFT) . "\n"; // full buffer dumped every time
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
printf("Output size: %d, expected %d\n", strlen($storage), 20 + 10 * 10);
|
||||||
|
|
||||||
|
?>
|
||||||
|
DONE
|
||||||
|
--EXPECT--
|
||||||
|
Output size: 120, expected 120
|
||||||
|
DONE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue