Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

html-sanitizer

> 编程语言
Open source

Sanitize untrustworthy HTML user input

387 stars0 likes0 views
WebsiteGitHub

About

Sanitize untrustworthy HTML user input

html-sanitizer

This library is deprecated as it was merged into Symfony as the HtmlSanitizer component in Symfony 6.1: https://symfony.com/doc/current/html_sanitizer.html html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing you to store it and display it safely. It has sensible defaults to provide a great developer experience while still being entirely configurable.

Internally, the sanitizer has a deep understanding of HTML: it parses the input and create a tree of DOMNode objects, which it uses to keep only the safe elements from the content. By using this technique, it is safe (it works with a strict whitelist), fast and easily extensible.

It also provides useful features such as the possibility to transform images or iframes URLs to HTTPS.

Symfony integration

This library is also available as a Symfony bundle.

Documentation

  1. Getting started
  2. Creating an extension to allow custom tags
  3. Configuration reference
  4. Comparison with HTMLPurifier

Security Issues

If you discover a security vulnerability within the sanitizer, please follow our disclosure procedure.

Backward Compatibility promise

This library follows the same Backward Compatibility promise as the Symfony framework: https://symfony.com/doc/current/contributing/code/bc.html

Note: many classes in this library are either marked @final or @internal. @internal classes are excluded from any Backward Compatiblity promise (you should not use them in your code) whereas @final classes can be used but should not be extended (use composition instead).

Thanks

Many thanks to:

  • The Open Web Application Security Project from which many of the tests of this library are extracted (more specifically from OWASP/java-html-sanitizer) ;
  • Masterminds/html5-php which is a great HTML5 parser, used by default in this library ;
  • The PHP League URI parser which allows this library to filter hosts safely ;

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言