[Question] Protection against XXS with user-generated input. #121

Closed
opened 2026-01-29 14:27:50 +00:00 by claunia · 2 comments
Owner

Originally created by @mloewent on GitHub (Jul 10, 2017).

Hi. I am wondering how I can protect against code execution using this library.
I want users to be able to add code snippets <script>alert("hi");</script>, but to make sure they are encoded.
Currently if a user writes a code snippet without putting it in a code block the snippet will be executed. Is there any way this library can help protect against this?

Thanks.

Originally created by @mloewent on GitHub (Jul 10, 2017). Hi. I am wondering how I can protect against code execution using this library. I want users to be able to add code snippets ```<script>alert("hi");</script>```, but to make sure they are encoded. Currently if a user writes a code snippet without putting it in a ```code block``` the snippet will be executed. Is there any way this library can help protect against this? Thanks.
claunia added the question label 2026-01-29 14:27:50 +00:00
Author
Owner

@mloewent commented on GitHub (Jul 10, 2017):

I have solved this by using a library to sanitize the HTML output of markdig, using a whitelist of HTML tags. Will leave this issue open in case you have any input.

@mloewent commented on GitHub (Jul 10, 2017): I have solved this by using a library to sanitize the HTML output of markdig, using a whitelist of HTML tags. Will leave this issue open in case you have any input.
Author
Owner

@xoofx commented on GitHub (Jul 11, 2017):

Yes, it is recommended to use a sanitizer on the HTML output directly

@xoofx commented on GitHub (Jul 11, 2017): Yes, it is recommended to use a sanitizer on the HTML output directly
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#121