Download the PHP package jeffersongoncalves/laravel-html-sanitizer without Composer
On this page you can find all versions of the php package jeffersongoncalves/laravel-html-sanitizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeffersongoncalves/laravel-html-sanitizer
More information about jeffersongoncalves/laravel-html-sanitizer
Files in jeffersongoncalves/laravel-html-sanitizer
Package laravel-html-sanitizer
Short Description This Laravel package provides a simple wrapper around the Symfony HTML Sanitizer to safely clean untrusted HTML. It strips scripts, inline event handlers, and Alpine attributes while keeping the presentational subset (headings, lists, tables, code blocks, images, links) that rendered Markdown and READMEs need. The package is easy to install and configure, seamlessly integrating with your existing Laravel application.
License MIT
Homepage https://github.com/jeffersongoncalves/laravel-html-sanitizer
Informations about the package laravel-html-sanitizer
Laravel HTML Sanitizer
This Laravel package provides a simple wrapper around the Symfony HTML Sanitizer to safely clean untrusted HTML. It strips scripts, inline event handlers, and Alpine attributes while keeping the presentational subset (headings, lists, tables, code blocks, images, links) that rendered Markdown and READMEs need. The package is easy to install and configure, seamlessly integrating with your existing Laravel application.
Installation
You can install the package via composer:
Usage
Pass any untrusted HTML through HtmlSanitizer::clean() before rendering it:
The sanitizer:
- drops
<script>,<style>and every event-handler attribute (onerror,onclick, ...); - strips Alpine
x-*attributes; - keeps the safe presentational subset: headings, lists, tables, code blocks, images and links;
- allows relative links/medias and the
https,http,mailtolink schemes (media schemes are limited tohttps/http—data:is excluded by default becausedata:image/svg+xmlpayloads can execute script); - preserves
class/idattributes (for heading permalinks, code-language hints and table wrappers) andwidth/heighton<img>.
It is intended for rendered HTML that originated from untrusted sources — GitHub READMEs of third-party repos and the Markdown body of imported articles — where raw HTML is enabled during rendering.
Configuration
Publish the config file to customise the allowed schemes, allowed attributes and the maximum input length:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Jèfferson Gonçalves
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-html-sanitizer with dependencies
illuminate/support Version ^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.14
symfony/html-sanitizer Version ^7.0|^8.0