feat: implement stage 2 of Milkdown integration (secure upload & xss guard)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Ganss.Xss;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
|
||||
namespace NexusReader.Infrastructure.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Infrastructure implementation of ISanitizerService using the Ganss.Xss HtmlSanitizer library.
|
||||
/// </summary>
|
||||
public class HtmlSanitizerService : ISanitizerService
|
||||
{
|
||||
private readonly HtmlSanitizer _sanitizer;
|
||||
|
||||
public HtmlSanitizerService()
|
||||
{
|
||||
_sanitizer = new HtmlSanitizer();
|
||||
|
||||
// Use default configuration which is extremely secure and strips
|
||||
// all JavaScript (script tags, onerror, onload, iframe, etc.)
|
||||
}
|
||||
|
||||
public string Sanitize(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
return _sanitizer.Sanitize(input);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user