Preventing XSS when user edits original Markdown input -


i'm building site user-generated content using pagedown (though form of markdown work), , wish store both original markdown , sanitized html in database users can go , edit original input. i'm not sure how re-display original markdown safely without being vulnerable xss, though. example, if user enters following input:

</textarea> <script>maliciouscode();</script> 

this fine when entered, since pagedown sanitizes , converts html, html gets sent server (which strips non-whitelisted html tags again anyways, since can't trust client-side sanitization alone). when original markdown gets sent client editing becomes:

<textarea class="wmd-input" id="wmd-input" name="wmd_area" > </textarea> <script>maliciouscode();</script> </textarea> 

and vulnerable xss. can advise how sites allow editing of stored markdown make safe, or better way should doing won't problem? know textarea tag stripped since it's not whitelisted, require stripping tags original markdown before converting html, i've read screw original markdown , shouldn't done.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -