-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|466|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Link Home -> Useful Apps


 
HoboBen
Created : 28 August 2011
Edited : 28 August 2011

HTML Purifier

HTML Purifier is a standards-compliant HTML filter library written in PHP

https://htmlpurifier.org/
My CMS will allow users to use HTML. However, I do not want them to use JavaScript. Additionally, the WYSIWYG editor generates HORRIBLE html. The solution to both problems is HTML Purifier:

---

HTML Purifier is an HTML filter that will take an arbitrary snippet of HTML and rigorously test, validate and filter it into a version that is safe for output onto webpages. It achieves this by:

Lexing (parsing into tokens) the document,
Executing various strategies on the tokens:
Removing all elements not in the whitelist,
Making the tokens well-formed,
Fixing the nesting of the nodes, and
Validating attributes of the nodes; and
Generating HTML from the purified tokens.

---

I'm very, very impressed.

Download the standalone version. Using it is as simple as:



---

output:


 

Comments