phlib/xss-sanitizer
PHP library for sanitizing untrusted HTML and preventing XSS. It parses user-supplied markup, strips dangerous tags, attributes and URLs, and returns safe HTML for rendering in web applications. Configurable rules suit comments, rich text and other user-generated content.
Consider it when:
Look elsewhere when:
symfony/html-sanitizer — are far easier to defend in a review.{{ }} escaping covers the feature, you need no sanitizer at all. If sanitization only matters at render time in the browser, a client-side library may be the better fit.For executives (one paragraph). We're evaluating a small open-source PHP component that strips dangerous markup from user-submitted HTML so features like comments, reviews, and CMS pages can support formatting without exposing customers to cross-site scripting. The upside is that sanitization is a solved problem we should license rather than invent; the caveats are that this particular library has a thin adoption footprint and carries an LGPL-3.0 licence, so it requires legal sign-off and a maintenance-risk review before we commit. The recommendation is to treat it as a candidate, not a decision: confirm the licence position, then choose between it and a better-established alternative based on security-review comfort rather than feature fit.
For engineering. The library is an allowlist-style HTML sanitizer — you define which elements and attributes survive, everything else is stripped. It installs via Composer and slots into the request or render path, so the integration is small. The open questions are: (1) pin the version and confirm the maintained branch, since release cadence is the main risk signal; (2) decide the sanitize-on-write vs. sanitize-on-render boundary and document it, because it changes what we retain for moderation; (3) agree the allowlist with product rather than letting defaults ship; and (4) verify the LGPL-3.0 position with legal, particularly if we ever patch or vendor the source. If any of those come back unfavourable, the fallback is the same integration point with a more established sanitizer — the surrounding design doesn't change, so we can decide late without blocking the feature.
How can I help you explore Laravel packages today?