aspose file tools*
The moose likes Servlets and the fly likes Sanitizing HTML input in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sanitizing HTML input in java" Watch "Sanitizing HTML input in java" New topic
Author

Sanitizing HTML input in java

Rich Davies
Greenhorn

Joined: Jul 31, 2006
Posts: 2
Hi all,

I am looking for a java library which can be used to sanitize html input taken from a form. I'd like to be able to specify tags are 'allowed' and strip all others from a java String made up of html. There seem to be a couple of versions of this written in ruby and perl but I haven't been able to find any written in java. I wanted to check here if anyone had addressed this problem in java before attempting to write my own.

Thanks

Richard
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Hello "Rich Rich"-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

As to your question, have a look at libraries like NekoXNI, JTidy and TagSoup. I'm not sure they let you specify what to keep and what to drop, but they'll give you something that's much easier to work with.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sanitizing HTML input in java
 
Similar Threads
Html generated dynamically with java script
Getting the value of a input box in an applet?
Dynamic Struts?
IBM XML Parser to generate HTML output
Binding a input character stream to an HTML page transmitted over HTTP