typo3/html-sanitizer
Standalone PHP HTML sanitizer from TYPO3. Define sanitizing rules via Behavior, apply multiple Visitors, and run through a Sanitizer built from reusable presets. Supports safe tag/attribute allowlists, value validation (e.g., regex), and encoding or removing invalid nodes.
Adopt When:
<script>, onclick, or custom elements).Look Elsewhere If:
Behavior/Visitor configurations)."This package is a security shield for our user-generated content. By automatically scrubbing malicious HTML (e.g., XSS attacks) while preserving safe formatting, we reduce risk without sacrificing functionality. It’s MIT-licensed, actively maintained, and integrates seamlessly with our Laravel stack—no vendor lock-in. The cost? Minimal dev effort; the payoff? Proactive protection against data breaches and compliance violations."
Key Metrics to Track:
*"This is a drop-in replacement for our current ad-hoc sanitization (or HTMLPurifier), offering:
<a href>, <img alt>) and reuse across the app.Visitor classes let us handle edge cases (e.g., transforming <typo3> tags to plaintext).Implementation Plan:
CommonBuilder preset.Behavior to enforce project-specific rules (e.g., disallow style attributes).Trade-offs:
Behavior/Visitor patterns (but docs/examples are solid).Alternatives Considered:
<svg onload=...>).Recommendation: Adopt for critical paths first (e.g., user profiles, admin panels), then expand."*
How can I help you explore Laravel packages today?