Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Xss Sanitizer Laravel Package

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.

Deep Wiki
Context7

Product Decisions This Supports

  • Whether to ship rich-text / user-generated HTML at all. Supporting formatted comments, reviews, forum posts, CMS pages, ticket bodies, or templated emails means accepting HTML from untrusted sources. A sanitizer is the enabling dependency for that product surface — without one, the choice collapses to "plain text only" or "accept the XSS risk."
  • Formatting policy as a product decision. An allowlist-based sanitizer forces an explicit decision about which tags and attributes users get (bold/italic/links/images/tables/code blocks). That's a UX and abuse-surface trade-off, not just an engineering detail — images and links in particular open hotlinking, tracking-pixel, and phishing-vector questions.
  • Build vs. buy. HTML sanitization is a commodity security primitive with a well-known failure mode (hand-rolled regex sanitizers get bypassed). The default position should be "adopt a library," so the real decision is which one, and whether the licence and maintenance profile are acceptable.
  • Security-debt and roadmap sequencing. If a UGC feature is on the roadmap, sanitization is a prerequisite item that needs to be scoped, budgeted, and staffed — not a ticket squeezed into the feature sprint.
  • Moderation and storage strategy. Choosing when to sanitize (on write vs. on render) affects whether you keep raw input for abuse investigation and re-processing, which in turn affects moderation tooling and data-retention commitments.
  • Compliance posture. LGPL-3.0 is a copyleft licence. For most PHP deployments, Composer-installed library use is fine, but some legal teams have blanket LGPL restrictions. That's a policy decision that needs to be settled before it becomes a re-architecture.

When to Consider This Package

Consider it when:

  • You have a concrete feature that must accept partially trusted HTML and preserve some formatting — sanitizing to plain text or escaping everything is not acceptable to the product.
  • You want a small, PHP-native, Composer-installable dependency with no service or extension requirements, and you're comfortable reviewing its configuration and allowlist yourself.
  • Your team already has it in the codebase or a sibling service, and standardizing beats introducing a second sanitizer.
  • Your threat model is the ordinary web one (stored/reflected XSS in rendered content) rather than a hardened, audit-heavy environment.

Look elsewhere when:

  • Adoption signal is weak. 16 stars and a composite health score around 0.27 is not evidence of a battle-tested security component. For a security-critical primitive, you want a project with broad usage, a visible security-response process, and a track record of prompt fixes.
  • Provenance is unclear. The repository is not confidently identified from the package metadata. You cannot review commit history, issue handling, or the maintainer's security policy — that's a supply-chain gap you should not paper over.
  • LGPL-3.0 is a blocker. If legal has a standing objection to copyleft dependencies, shortlist permissively licensed alternatives instead of litigating it per-feature.
  • You need stronger guarantees. If you require W3C-style sanitization semantics, well-audited default policies, CSS sanitization, or configuration that security reviewers will recognize, established alternatives — HTMLPurifier (often via a Laravel wrapper) or symfony/html-sanitizer — are far easier to defend in a review.
  • You don't actually need HTML. If Blade's {{ }} 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.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib