Selective HTML escaping with Java
-
23-06-2021 - |
Question
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
La solution 2
Using a regular expression was the answer here. There was no solution to this issue in any of the libraries available to me.
Autres conseils
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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow