databinding.WebSecurity.HtmlSanitizer
2025.7.18.3
Prefix Reserved
See the version list below for details.
dotnet add package databinding.WebSecurity.HtmlSanitizer --version 2025.7.18.3
NuGet\Install-Package databinding.WebSecurity.HtmlSanitizer -Version 2025.7.18.3
<PackageReference Include="databinding.WebSecurity.HtmlSanitizer" Version="2025.7.18.3" />
<PackageVersion Include="databinding.WebSecurity.HtmlSanitizer" Version="2025.7.18.3" />
<PackageReference Include="databinding.WebSecurity.HtmlSanitizer" />
paket add databinding.WebSecurity.HtmlSanitizer --version 2025.7.18.3
#r "nuget: databinding.WebSecurity.HtmlSanitizer, 2025.7.18.3"
#:package databinding.WebSecurity.HtmlSanitizer@2025.7.18.3
#addin nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2025.7.18.3
#tool nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2025.7.18.3
databinding.WebSecurity.HtmlSanitizer
databinding.WebSecurity.HtmlSanitizer is a .NET 8+ library designed to sanitize HTML content by removing potentially harmful tags, attributes, styles, and CSS classes. It ensures that the HTML content adheres to a specified set of allowed elements and attributes, making it safe for use in web applications.
This package is based on Ganss.HtmlSanitizer without backward compatibility to .NET Framework.
Getting started
Prerequisites
- .NET 8 or later
- Visual Studio 2022/Code or later
Installation
To install the library, you can use the NuGet package manager:
dotnet add package databinding.WebSecurity.HtmlSanitizer
Usage
Here's a basic example of how to use it:
using databinding.WebSecurity.HtmlSanitizer;
var options = new HtmlSanitizerOptions
{
AllowedTags = new HashSet { "a", "p", "strong" },
AllowedAttributes = new HashSet { "href", "style" },
AllowedCssProperties = new HashSet { "color" },
UriAttributes = new HashSet { "href" }
};
var sanitizer = new HtmlSanitizer(options);
var sanitizedHtml = sanitizer.Sanitize("<p onclick="alert('xss')">Test</p>");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AngleSharp (>= 1.2.0)
- AngleSharp.Css (>= 1.0.0-beta.151)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on databinding.WebSecurity.HtmlSanitizer:
Package | Downloads |
---|---|
databinding.WebSecurity.HtmlSanitizer.AspNetCore
databinding.WebSecurity.HtmlSanitizer.AspNetCore provides ActionFilter for use in MVC and API applications. These remove HTML from user input to avoid XSS. Only simple HTML tags for rich text editors are allowed. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2025.7.23.2 | 587 | 7/23/2025 |
2025.7.23.1 | 555 | 7/23/2025 |
2025.7.22.3 | 551 | 7/22/2025 |
2025.7.18.3 | 127 | 7/18/2025 |
2025.4.28.1 | 191 | 4/28/2025 |
2025.4.16.3 | 240 | 4/16/2025 |
2025.4.16.1 | 217 | 4/16/2025 |
2025.4.14.1 | 232 | 4/14/2025 |
2025.4.3.1 | 197 | 4/3/2025 |
2025.4.1.1 | 184 | 4/1/2025 |
2025.3.26.1 | 483 | 3/26/2025 |
2025.3.24.1 | 503 | 3/24/2025 |
2025.3.21.1 | 129 | 3/21/2025 |
2025.2.18.1 | 132 | 2/18/2025 |
2025.2.12.2 | 149 | 2/12/2025 |
2025.2.5.2 | 135 | 2/5/2025 |
2025.2.4.1 | 132 | 2/4/2025 |
2025.2.3.6 | 127 | 2/3/2025 |
2025.1.21.11 | 138 | 1/21/2025 |
2025.1.21.10 | 120 | 1/21/2025 |
2025.1.21.9 | 123 | 1/21/2025 |
2025.1.21.5 | 120 | 1/21/2025 |