1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 20:13:22 +01:00
Nils Adermann a5ef6c3b20 [ticket/10188] Prevent semi-compressed output
When a non-fatal error occurs at the beginning of the script before any custom
error handler is set one of two situations can be encountered:

1) if the ini option output buffer is disabled:
      - headers are sent to the http client
      - the error message is output
2) if the ini option output_buffer is enabled or the script
   is run within an ob_start()/ob_end() wrapper:
      - the error message is written to the output buffer

Once the script reaches page_header() phpbb starts gzip compression if enabled.
This is done through ob_start with a ob_gzhandler as a callback. The
compression is skipped if headers have already been sent. In situation 1) the
error message sent in plain text comes with headers and this gzip compression
is skipped. The client receives a plaintext version of the page. However in
situation 2) headers have not been sent yet and the rest of the page will be
compressed. The result is a plaintext error message followed by compressed
output. The client does not understand this output resulting in either an
error message or simply a blank page in the browser.

In addition to the above situation this problem occurs with errors that are
triggered after the custom error handler is loaded. The problem has been
noticed before, and a workaround was found. The error handler would call
ob_flush() for particular configuration settings before outputting the error
message. This resulted in headers being sent when output buffering was enabled
thus disabling gzip compression for the rest of the page. The constraints under
which ob_flush() was called were lessened over time whenever a new case was
found that would trigger this problem. Eventually ob_flush() would be called
even when code causing an E_NOTICE was simply run within an ob_start/ob_end.
This makes it impossible to use output buffering to retrieve the content of an
error message without prohibiting the page from setting headers afterwards.

This commit removes all flushing in msg_handler completely and instead fixes
the problem for both errors before and after the error handler is registered.
GZIP compression is only enabled if there is at most one level of output
buffering (e.g. the output_buffer php.ini option is enabled) and if there has
not yet been any output in this buffer. This should avoid any partial output
compression.

PHPBB3-10188
2011-06-26 20:31:22 +02:00

phpBB

ABOUT

phpBB is a free bulletin board written in PHP.

COMMUNITY

Find support and lots more on phpBB.com! Discuss the development on area51.

CONTRIBUTE

  1. Create an account on phpBB.com
  2. Create a ticket (unless there already is one)
  3. Read our Git Contribution Guidelines; if you're new to git, also read the introduction guide
  4. Send us a pull request

LICENSE

GNU General Public License v2

Description
No description provided
Readme 192 MiB
Languages
PHP 86.9%
HTML 8.5%
JavaScript 2.7%
CSS 1.6%
Shell 0.2%