I have a markdown textarea (just like stackoverflow) and I want to allow code samples like this:
<script>alert('Hello world')</script>
as well as basic html formatting like <b>bold text</b>
: bold text.
How to do validation and encoding so that it will prevent XSS attacks but also allow scenarios above?
I know there is HTML Sanitizer, but it probably won't work with markdown formatting by default.