Java, JavaScript: Avoid escaping particular HTML tags -
i using org.apache.commons.lang.stringescapeutils
escape html tags:
stringescapeutils.escapehtml(str);
what want avoid escaping few particular tags. e.g.
<h1>this h1</h1> <ul> <li></li> <li></li> </ul>
after escaping should connvert <
<
, >
>
except <ul>
, <li>
tag. here don't want escape <ul>
<li>
tags because in html page have show content list need ul , li.
how can in java , javascript.
you don't want simple string escape util, you're using.
what want html sanitizer, owasp java html sanitizer. allows whitelists of html tags not escape, e.g., custom html policies can specify allowed tags, in case default sanitizers don't meet needs.
other libraries this, jsoup cleaning functionality.
Comments
Post a Comment