All Projects → RickStrahl → Htmlsanitizer

RickStrahl / Htmlsanitizer

A base Html Sanitizer for .NET

HtmlSanitizer

This is the code for a blog article on a quick and dirty HTML Sanitation routine in C# which is discussed here:

.NET HTML Sanitation for rich HTML Input

The idea is that in some applications it's necessary to capture HTML as part of user input, and that there's a need to sanitize the HTML input to prevent malicious code to fire. This routine parses captured HTML input and strips elements and attributes that are considered potentially malicious.

This code uses a blacklist approach to blocking potentially malicious input HTML text posted and you can modify the blacklist according to your needs.

This is not meant to be a bullet proof implementation, but rather a functional and extensible one that you can tweak for you specific requirements.

For more detailed info please refer to the Blog Post which discusses the reasoning behind this routine in more detail.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].