stevebauman/purify
Laravel wrapper for HTMLPurifier to sanitize user-submitted HTML. Clean strings or arrays via a simple facade, with support for dynamic per-call configuration, published config, and caching options to keep output safe and consistent.
default, comments), enabling granular control over sanitization rules per use case (e.g., user-generated content vs. admin panels).Definition, CssDefinition), making it adaptable to niche requirements (e.g., Trix editor support, custom elements/attributes).composer require, vendor:publish), with minimal boilerplate. The facade (Purify) provides a clean API for sanitization.ezyang/htmlpurifier (v4.16+), which is stable but may introduce breaking changes in minor updates. The package abstracts most of these risks, but TPMs should monitor upstream updates.onclick) could introduce vulnerabilities.stevebauman/purify is actively maintained, htmlpurifier is a long-standing library with occasional breaking changes. Monitor for Laravel 11+ compatibility if upgrading.data-*)? If so, how will these be audited?onSet) or output (onGet)? (Package recommends onGet for flexibility.)PurifyHtmlOnGet casts be leveraged?DOMParser, htmlentities) that could conflict?Purify::clean() for ad-hoc sanitization.PurifyHtmlOnGet casts for automatic sanitization on model retrieval.htmlpurifier can be used standalone if needed (though this requires manual setup).strip_tags, regex, or manual DOM parsing).vendor:publish).default configuration and test against a subset of user-generated content.Purify::clean().comments, admin) in config/purify.php.PurifyHtmlOnGet casts to Eloquent models for passive sanitization.casts() method syntax.spatie/laravel-html). Audit dependencies to avoid duplication.Purify::clean()).PurifyHtmlOnGet casts to critical models (e.g., Post, Comment).request()->purify()).comments, rich_text).config/purify.php for easy updates.purify.php overrides in .env) for staging/production differences.TrixPurifierDefinitions) alongside the app.stevebauman/purify and htmlpurifier for breaking changes.purify:clear during deployments if definitions change.Purify::clean($input, true) to inspect sanitized output and identify issues.HTML.Allowed or CSS.AllowedProperties to permit legitimate content.javascript: in href).data-* attributes allowed?").How can I help you explore Laravel packages today?