简体   繁体   中英

Selective HTML escaping with Java

Is there anything in JavaSE , Spring or Apache Commons StringUtils that would allow me to strip out HTML from a String but also supply a whitelist of HTML entities that I would like to allow?

Thanks

You can take a look at OWASP AntiSamy project . It has default policy files, but you can tailor them to your needs; see the Developer Guide for details on that.

Using a regular expression was the answer here. There was no solution to this issue in any of the libraries available to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM