PHPackages                             cebugle/laravel-html-purifier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. cebugle/laravel-html-purifier

ActivePackage[Security](/categories/security)

cebugle/laravel-html-purifier
=============================

Laravel Html Purifier Package

v1.0.1(3y ago)016MITPHPPHP ^8.2

Since Mar 6Pushed 3y agoCompare

[ Source](https://github.com/cebugle/laravel-html-purifier)[ Packagist](https://packagist.org/packages/cebugle/laravel-html-purifier)[ Docs](https://github.com/cebugle/laravel-html-purifier)[ RSS](/packages/cebugle-laravel-html-purifier/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

HTMLPurifier for Laravel
========================

[](#htmlpurifier-for-laravel)

[![Build Status](https://camo.githubusercontent.com/89bd025da98024db8b737f0d121f7c2a690595b18a1747838de7f5c1fdf2a3e3/68747470733a2f2f7472617669732d63692e6f72672f6d6577656273747564696f2f50757269666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/github/mewebstudio/Purifier)[![codecov](https://camo.githubusercontent.com/807a7d05db57285f22357db96e478c133ddc2a969ce9b87112d7483b2f9a4731/68747470733a2f2f636f6465636f762e696f2f67682f6d6577656273747564696f2f50757269666965722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mewebstudio/Purifier)[![Latest Stable Version](https://camo.githubusercontent.com/a14086c743b74344d73d377e56bc76ad735eb1bd1cd066d2a4de9c562042054e/68747470733a2f2f706f7365722e707567782e6f72672f63656275676c652f6c61726176656c2d68746d6c2d70757269666965722f762f737461626c652e737667)](https://packagist.org/packages/cebugle/laravel-html-purifier)[![Latest Unstable Version](https://camo.githubusercontent.com/1882b1441969f0082d233c1bbb44210b55d100110a8f88702946630cc33e8a1c/68747470733a2f2f706f7365722e707567782e6f72672f63656275676c652f6c61726176656c2d68746d6c2d70757269666965722f762f756e737461626c652e737667)](https://packagist.org/packages/cebugle/laravel-html-purifier)[![License](https://camo.githubusercontent.com/1f78a1d80c0abc82527738ae6b23e9da22bc665a79a7fcc52d9ab449869acfa3/68747470733a2f2f706f7365722e707567782e6f72672f63656275676c652f6c61726176656c2d68746d6c2d70757269666965722f6c6963656e73652e737667)](https://packagist.org/packages/cebugle/laravel-html-purifier)[![Total Downloads](https://camo.githubusercontent.com/2f9f4a3a0d23e0e8d1e0d569842da5f5944670b3836eae7ad8bc43b7d211a6e0/68747470733a2f2f706f7365722e707567782e6f72672f63656275676c652f6c61726176656c2d68746d6c2d70757269666965722f646f776e6c6f6164732e737667)](https://packagist.org/packages/cebugle/laravel-html-purifier)

A simple [Laravel](http://www.laravel.com/) service provider for easily using [HTMLPurifier](http://htmlpurifier.org/) inside Laravel. From their website:

> HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications. Tired of using BBCode due to the current landscape of deficient or insecure HTML filters? Have a WYSIWYG editor but never been able to use it? Looking for high-quality, standards-compliant, open-source components for that application you're building? HTML Purifier is for you!

Installation
------------

[](#installation)

Require this package with composer:

```
composer require cebugle/laravel-html-purifier

```

The service provider will be auto-discovered. You do not need to add the provider anywhere.

Usage
-----

[](#usage)

Use these methods inside your requests or middleware, wherever you need the HTML cleaned up:

```
clean(Input::get('inputname'));
```

or

```
Purifier::clean(Input::get('inputname'));
```

dynamic config

```
clean('This is my H1 title', 'titles');
clean('This is my H1 title', array('Attr.EnableID' => true));
```

or

```
Purifier::clean('This is my H1 title', 'titles');
Purifier::clean('This is my H1 title', array('Attr.EnableID' => true));
```

use [URI filter](http://htmlpurifier.org/docs/enduser-uri-filter.html)

```
Purifier::clean('This is my H1 title', 'titles', function (HTMLPurifier_Config $config) {
    $uri = $config->getDefinition('URI');
    $uri->addFilter(new HTMLPurifier_URIFilter_NameOfFilter(), $config);
});
```

Alternatively, in Laravel 7+, if you're looking to clean your HTML inside your Eloquent models, you can use our custom casts:

```
