---
title: "Whoops: XSS and output buffers on the PHP error page"
description: "In Whoops we limited clickable links on the error page to http and https to close an XSS, and fixed output buffer cleanup under zlib compression, in PHP."
url: "https://vulcode.com/en/opensource/contributions/whoops"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

filp/whoops

# Whoops

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

[See the repository](https://github.com/filp/whoops) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: PHP
- **GitHub stars**: 13,231
- **Merged changes**: 2
- **Project site**: [filp.github.io](http://filp.github.io/whoops/)

## 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](https://github.com/filp/whoops/pull/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](https://github.com/filp/whoops/pull/795)

## Merged changes 2

- [#795 Stop output buffer cleanup at buffers that cannot be removed Merged 3 October 2026](https://github.com/filp/whoops/pull/795)

- [#794 Restrict escapeButPreserveUris() to http/https schemes (fixes #791) Merged 5 September 2026](https://github.com/filp/whoops/pull/794)

## 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](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**PHPMailer** PHP · 22,347 stars The classic PHP library for sending email, used by WordPress and many other systems.](https://vulcode.com/en/opensource/contributions/phpmailer)

- [**Monolog** PHP · 21,407 stars A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.](https://vulcode.com/en/opensource/contributions/monolog)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

- [**Doctrine Lexer** PHP · 11,141 stars A base for lexers used by recursive descent parsers in PHP, used by Doctrine ORM among others.](https://vulcode.com/en/opensource/contributions/doctrine-lexer)

## Describe your project.

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

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
