Reputation: 27996
I'm writing a java webapp and I'd like to let my users enter text containing markup that is XSS / Cross-Site-Scripting safe. I'd like to save the user generated markup to a database and display it as HTML.
I am aware of markdown but this allows raw HTML to be entered which is not XSS safe.
Are there any wiki-like / markdown-like interpreters in java that are XSS safe? I'd also like to hear of any javascript / wysiwig editors that might help here.
Alternatively, are there any XSS filters in java that can sanitize HTML so that it is XSS safe.
Upvotes: 2
Views: 850
Reputation: 6083
Take a look at JSoup, which allows you to specify a Whitelist: http://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer
Upvotes: 2