2017 © Pedro Peláez
 

library purifier

Laravel 5 HtmlPurifier Package

image

moomnng/purifier

Laravel 5 HtmlPurifier Package

  • Sunday, January 28, 2018
  • by moomnng
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 106 Forks
  • 0 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

HTMLPurifier for Laravel 5

Build Status Scrutinizer Code Quality, (*1)

A simple Laravel 5 service provider for including the HTMLPurifier for Laravel 5., (*2)

for Laravel 4 HTMLPurifier for Laravel 4, (*3)

This package can be installed via Composer by requiring the mews/purifier package in your project's composer.json:, (*4)

{
    "require": {
        "laravel/framework": "~5.0",
        "mews/purifier": "~2.0",
    }
}

or, (*5)

Require this package with composer:, (*6)

composer require mews/purifier

Update your packages with composer update or install with composer install., (*7)

Usage

To use the HTMLPurifier Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this., (*8)

Find the providers key in config/app.php and register the HTMLPurifier Service Provider., (*9)

    'providers' => [
        // ...
        Mews\Purifier\PurifierServiceProvider::class,
    ]

Find the aliases key in app/config/app.php., (*10)

    'aliases' => [
        // ...
        'Purifier' => Mews\Purifier\Facades\Purifier::class,
    ]

Configuration

To use your own settings, publish config., (*11)

$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider", (*12)

Config file config/purifier.php should like this, (*13)


return [ 'encoding' => 'UTF-8', 'finalize' => true, 'cachePath' => storage_path('app/purifier'), 'cacheFileMode' => 0755, 'settings' => [ 'default' => [ 'HTML.Doctype' => 'HTML 4.01 Transitional', 'HTML.Allowed' => 'div,b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]', 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align', 'AutoFormat.AutoParagraph' => true, 'AutoFormat.RemoveEmpty' => true, ], 'test' => [ 'Attr.EnableID' => 'true', ], "youtube" => [ "HTML.SafeIframe" => 'true', "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", ], 'custom_definition' => [ 'id' => 'html5-definitions', 'rev' => 1, 'debug' => false, 'elements' => [ // http://developers.whatwg.org/sections.html ['section', 'Block', 'Flow', 'Common'], ['nav', 'Block', 'Flow', 'Common'], ['article', 'Block', 'Flow', 'Common'], ['aside', 'Block', 'Flow', 'Common'], ['header', 'Block', 'Flow', 'Common'], ['footer', 'Block', 'Flow', 'Common'], // Content model actually excludes several tags, not modelled here ['address', 'Block', 'Flow', 'Common'], ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'], // http://developers.whatwg.org/grouping-content.html ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'], ['figcaption', 'Inline', 'Flow', 'Common'], // http://developers.whatwg.org/the-video-element.html#the-video-element ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', 'width' => 'Length', 'height' => 'Length', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool', ]], ['source', 'Block', 'Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', ]], // http://developers.whatwg.org/text-level-semantics.html ['s', 'Inline', 'Inline', 'Common'], ['var', 'Inline', 'Inline', 'Common'], ['sub', 'Inline', 'Inline', 'Common'], ['sup', 'Inline', 'Inline', 'Common'], ['mark', 'Inline', 'Inline', 'Common'], ['wbr', 'Inline', 'Empty', 'Core'], // http://developers.whatwg.org/edits.html ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']], ], 'attributes' => [ ['iframe', 'allowfullscreen', 'Bool'], ['table', 'height', 'Text'], ['td', 'border', 'Text'], ['th', 'border', 'Text'], ['tr', 'width', 'Text'], ['tr', 'height', 'Text'], ['tr', 'border', 'Text'], ], ], 'custom_attributes' => [ ['a', 'target', 'Enum#_blank,_self,_target,_top'], ], 'custom_elements' => [ ['u', 'Inline', 'Inline', 'Common'], ], ], ];

Example

default, (*14)

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

or, (*15)

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

dynamic config, (*16)

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

or, (*17)

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

for Laravel 4 HTMLPurifier for Laravel 4, (*18)

The Versions

28/01 2018

dev-master

9999999-dev https://github.com/moomnng/Purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

by todaychen

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

11/09 2017

2.0.9

2.0.9.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

03/06 2016

dev-master-l4

dev-master-l4 http://github.com/mewebstudio/Purifier

HTMLPurifier Package for Laravel 4

  Sources   Download

LGPL

The Requires

 

laravel laravel 4 purifier l4 htmlpurifier

26/04 2016

2.0.5

2.0.5.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

02/02 2016

2.0.4

2.0.4.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

31/08 2015

2.0.3

2.0.3.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

28/08 2015

2.0.2

2.0.2.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

29/07 2015

2.0.1

2.0.1.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

11/04 2015

2.0.0

2.0.0.0 https://github.com/mewebstudio/purifier

Laravel 5 HtmlPurifier Package

  Sources   Download

MIT

The Requires

 

The Development Requires

security xss purifier laravel5 security htmlpurifier laravel5 htmlpurifier laravel5 purifier

31/12 2014

1.0.2

1.0.2.0 http://github.com/mewebstudio/Purifier

HTMLPurifier Package for Laravel 4

  Sources   Download

LGPL

The Requires

 

laravel laravel 4 purifier l4 htmlpurifier

25/01 2014

1.0.1

1.0.1.0 http://github.com/mewebstudio/Purifier

HTMLPurifier Package for Laravel 4

  Sources   Download

LGPL

The Requires

 

laravel laravel 4 purifier l4 htmlpurifier