troubleshooting Question

How to escape unsafe HTML tags

Avatar of Rohit Bajaj
Rohit BajajFlag for India asked on
HTMLJavaScriptjQuery
4 Comments1 Solution399 ViewsLast Modified:
HI,
I am making a markdown web application where user can type in a markdown and see its equivalent rendering.
The issue is for example if the user types :
<script>alert(10)</script> then on displaying the markdown as html this script will get executed...
I am using marked library to convert raw markdown to HTML
One solution is to remove all unsafe tags.. Other is to escape unsafe HTML tags...
The markdown that github uses... escapes the unsafe tags..
How does it do it ?
Any library or way where i can escape the unsafe HTML tags ?
This has to done using a js /jquery library...etc..

Thanks
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros