HTML filtering utility for Java

This utility is a single class, HTMLInputFilter, which can be used to parse user-submitted input and sanitize it against potential cross site scripting attacks, malicious html, or simply badly formed html. This version, written in Java, is largely a translation of lib_filter, the original work of Cal Henderson written in PHP.

Combined with this code is an inner Test class for unit testing, designed to be executed in JUnit within Eclipse. The download archive includes the necessary JUnit jar for running the tests.

Processing HTML Input

Sample usage:

// retrieve input from user...
String input = ...
String clean = new HTMLInputFilter().filter( input );

This code is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. If you find any bugs, or have any suggestions on improvement, please contact me.