OWASP / java-html-sanitizer

Takes third-party HTML and produces HTML that is safe to embed in your web application. Fast and easy to configure.
Other
833 stars 210 forks source link

Encoding malicious code instead of removing it #298

Open bmscodespace opened 5 months ago

bmscodespace commented 5 months ago

Hi,

is it possible to build a policy that, instead of removing problematic parts of a html string, just encodes those parts in such a way that they can do no harm when the string is used in a html-page? So <script>alert`1`</script> would then be replaced by something like &lt;script&gt;alert`1`&lt;/script&gt;.

Thank you for any answer ;)

p.s. the idea behind my question is that I would like to use a policy that does not know if it deals with a string that will be used as inner html or as an "ordinary text field" with no html but where we could read a text about the " Githubissues.

  • Githubissues is a development platform for aggregating issues.