Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sanitizing HTML input in java

 
Rich Davies
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic