All contributions

filp/whoops

Whoops

A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.

Language
PHP
GitHub stars
13,231
Merged changes
2
Project site
filp.github.io

What we changed

Output buffer cleanup stops at buffers that cannot be removed, such as zlib compression, and the error page turns only http and https addresses into clickable links.

What this work shows

  • XSS through URI schemes
  • Regular expressions in PHP
  • PHP output buffers and zlib
  • Mocking with Mockery
What was broken

A javascript:// link was clickable

escapeButPreserveUris() turned URLs with any scheme into clickable links, including javascript://, vbscript:// and data://. Exception text carrying such a URL became a link on the error page that ran a script when clicked. The [A-z] class in the pattern also matched several punctuation characters.

How we fixed it

Links only for http and https

The pattern now accepts only the https? scheme, case-insensitively, and any other scheme stays as plain escaped text. Ordinary http and https URLs come out as before, which two new tests check.

#794

What was broken

The exception got lost under zlib compression

With zlib.output_compression on, the output buffer cannot be removed once it has sent output. The loop that cleans up buffers hit ob_end_clean(): Failed to discard buffer, and the original exception was lost.

How we fixed it

Cleanup stops at a non-removable buffer

A new isOutputBufferRemovable() method in SystemFacade checks the PHP_OUTPUT_HANDLER_REMOVABLE flag, and the loop stops at the first buffer without it. The fix shipped in release 2.18.6.

#795

Merged changes 2

  1. #795 Stop output buffer cleanup at buffers that cannot be removed Merged 3 October 2026
  2. #794 Restrict escapeButPreserveUris() to http/https schemes (fixes #791) Merged 5 September 2026

What it taught us

A developer tool also renders other people's data, so we limit links to http and https to close an XSS. Around PHP output buffers with zlib compression, exception handling has to keep the original error from being lost.

More about this technology: PHP

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.