2017 © Pedro Peláez
 

library htmlawed

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

image

vanilla/htmlawed

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  • Monday, April 2, 2018
  • by tburry
  • Repository
  • 14 Watchers
  • 23 Stars
  • 62,383 Installations
  • HTML
  • 4 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 22 Versions
  • 12 % Grown

The README.md

htmLawed

Build Status Coverage Packagist Version LGPL-3.0, (*1)

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS., (*2)

Why use htmLawed?

If your website has any user-generated content then you need to worry about cross-site scripting (XSS). htmLawed will take a piece of potentially malicious html and remove the malicious code, leaving the rest of html behind., (*3)

Beyond the base htmLawed library, this package makes htmLawed a composer package and wraps it in an object so that it can be autoloaded., (*4)

Installation

htmLawed requres PHP 5.4 or higher, (*5)

htmLawed is PSR-4 compliant and can be installed using composer. Just add vanilla/htmlawed to your composer.json., (*6)

"require": {
    "vanilla/htmlawed": "~1.0"
}

Example

echo Htmlawed::filter('

<

h1>Hello world!');
// Outputs: '

Hello world!

'. echo Htmlawed::filter('<i>nothing to see</i>') // Outputs: '<i>nothing to see</i>alert("xss")'

Configs and Specs

The htmLawed filter takes two optional parameters: $config and $spec. This library provides sensible defaults to these parameters, but you can override them in Htmlawed::filter()., (*7)

$xss = "<i>nothing to see ";

// Pass an empty config and spec for no filtering of malicious code.
echo Htmlawed::filter($xss, [], []);
// Outputs: '<i>nothing to see </i>'

// Pass safe=1 to turn on all the safe options.
echo Htmlawed::filter($xss, ['safe' => 1]);
// Outputs: '<i>nothing to see alert("xss")</i>'

// We provide a convenience method that strips all tags that aren't supposed to be in rss feeds.
echo Htmlawed::filterRSS('<html><body>

Hello world!

</body></html>'); // Outputs: '

Hello world!

'

See the htmLawed documentation for the full list of options., (*8)

Differences in Vanilla's version of Htmlawed

We try and use the most recent version of htmLawed with as few changes as possible so that bug fixes and security releases can be merged from the main project. However, We've made a few changes in the source code., (*9)

  • Balance tags (hl_bal) before validating tags (hl_tag). We found some cases where an unbalanced script tag would not get removed and this addresses that issue.
  • Don't add an extra <div> inside of <blockquote> tags.
  • Remove naked <span>.
  • Change indentation from 1 space to 4 spaces.

If the original author of htmLawed wants to make any of these changes upstream please get in contact with support@vanillaforums.com., (*10)

The Versions

02/04 2018

dev-fix/htmllawed-strip-download

dev-fix/htmllawed-strip-download

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

13/09 2017

dev-master

9999999-dev

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

13/09 2017

v2.2.4.1

2.2.4.1

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

29/08 2017

dev-feature/travis-php72

dev-feature/travis-php72

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

29/05 2017

dev-fix/hhvm

dev-fix/hhvm

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

17/05 2017

v2.2.1.1

2.2.1.1

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

17/05 2017

dev-feature/update-1dot2dot1dot1

dev-feature/update-1dot2dot1dot1

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

16/05 2017

v2.2.1

2.2.1.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

16/05 2017

dev-feature/update-1dot2dot1

dev-feature/update-1dot2dot1

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

20/04 2017

v2.2.0.1

2.2.0.1

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

04/04 2017

dev-upstream

dev-upstream

  Sources   Download

31/03 2017

dev-fix/remove-empty-paragraphs

dev-fix/remove-empty-paragraphs

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

28/03 2017

v2.2

2.2.0.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

14/04 2016

v2.1.22

2.1.22.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

18/01 2016

v1.2.4

1.2.4.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

15/01 2016

dev-hotfix/aggressive-span-stripping

dev-hotfix/aggressive-span-stripping

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

05/02 2015

v1.2.3

1.2.3.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

03/02 2015

v1.2.2

1.2.2.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

22/08 2014

v1.2.0

1.2.0.0

A composer wrapper for the htmLawed library to purify & filter HTML. Tested with PHPUnit and PhantomJS!

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

16/07 2014

v1.1.0

1.1.0.0

A composer wrapper for the htmLawed library to purify & filter HTML.

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

16/07 2014

v1.0.1

1.0.1.0

A composer wrapper for the htmLawed library to purify & filter HTML.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Todd Burry

16/07 2014

v1.0.0

1.0.0.0

A composer wrapper for the htmLawed library to purify & filter HTML.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Todd Burry