📦 Purifier/ mewebstudio
HTMLPurifier for Laravel 5+
Открыть на GitHub ↗обновлён 1мес назад
Звёзды
★ 2.0k
Форки
241
За неделю
—
За месяц
—
Рост %
—
Язык
PHP
Установка и запуск
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
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:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Mews\Purifier\Casts\CleanHtml;
use Mews\Purifier\Casts\CleanHtmlInput;
use Mews\Purifier\Casts\CleanHtmlOutput;
class Monster extends Model
{
protected $casts = [
'bio' => CleanHtml::class, // cleans both when getting and setting the value
'description' => CleanHtmlInput::class, // cleans when setting the value
'history' => CleanHtmlOutput::class, // cleans when getting the value
];
}
Из README репозитория · полный README на GitHub
Категории
Теги
cleaninghtmlpurifierlaravelphp