Skip to content


Subversion checkout URL

You can clone with
Download ZIP
PHP HTML filtering library
PHP Perl6 Perl Makefile
Branch: master
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.travis.yml Start testing against 5.5
Makefile make running tests easier don't create an instance of the filter by default - let the calling c…
composer.json make it into a composer package
lib_filter.php ws cleanup


Build Status

A PHP HTML-input-filtering library. You can read about how it works in this article (part 2).


This library can be used to filter HTML directly entered by users, or recieved via a richtext editor. The library ensures that no harmful HTML will be output into the browser, avoiding all forms of XSS attacks.


$filter = new lib_filter();

$safe_html = $filter->go($user_input);

echo $safe_html;


This library has been used in many projects and frameworks, ported to other languages and used as the basis for other filtering libraries. For instance:


If you have perl's Test::Harness installed (you almost certainly do), you can run the tests using:

make test

When submitting patches or pull-requests, bonus points are given for adding test cases.

Something went wrong with that request. Please try again.