databinding.WebSecurity.HtmlSanitizer
2025.2.18.1
Prefix Reserved
dotnet add package databinding.WebSecurity.HtmlSanitizer --version 2025.2.18.1
NuGet\Install-Package databinding.WebSecurity.HtmlSanitizer -Version 2025.2.18.1
<PackageReference Include="databinding.WebSecurity.HtmlSanitizer" Version="2025.2.18.1" />
paket add databinding.WebSecurity.HtmlSanitizer --version 2025.2.18.1
#r "nuget: databinding.WebSecurity.HtmlSanitizer, 2025.2.18.1"
// Install databinding.WebSecurity.HtmlSanitizer as a Cake Addin #addin nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2025.2.18.1 // Install databinding.WebSecurity.HtmlSanitizer as a Cake Tool #tool nuget:?package=databinding.WebSecurity.HtmlSanitizer&version=2025.2.18.1
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. |
-
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.2.18.1 | 89 | 2/18/2025 |
2025.2.12.2 | 119 | 2/12/2025 |
2025.2.5.2 | 102 | 2/5/2025 |
2025.2.4.1 | 96 | 2/4/2025 |
2025.2.3.6 | 101 | 2/3/2025 |
2025.1.21.11 | 107 | 1/21/2025 |
2025.1.21.10 | 90 | 1/21/2025 |
2025.1.21.9 | 90 | 1/21/2025 |
2025.1.21.5 | 90 | 1/21/2025 |