Refaktorierung für HTML-Sanitization mit neuer Sanitizer-Klasse.

- Bestehende Sanitization überarbeitet.
- Injektionsmethode für flexible Konfiguration implementiert.
- Wichtige Abschnitte in `show-envelope` hervorgehoben.
This commit is contained in:
Developer 02
2024-07-18 10:52:39 +02:00
parent 1c2df71e0f
commit 43ae15b71c
9 changed files with 61 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ using Microsoft.Extensions.Options;
using EnvelopeGenerator.Application;
using DigitalData.EmailProfilerDispatcher;
using EnvelopeGenerator.Infrastructure;
using EnvelopeGenerator.Web.Sanitizers;
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("Logging initialized!");
@@ -126,11 +127,15 @@ try
builder.Services.AddSingleton(HtmlEncoder.Default);
builder.Services.AddSingleton(UrlEncoder.Default);
builder.Services.AddSingleton(_ =>
builder.Services.AddSanitizer<HtmlSanitizer>();
builder.Services.AddSanitizer<HighlightHtmlSanitizer>(s =>
{
var sanitizer = new HtmlSanitizer();
//configure sanitzer
return sanitizer;
s.AllowedTags.Add("a");
s.AllowedAttributes.Add("href");
s.AllowedAttributes.Add("class");
s.AllowedClasses.Add("highlight");
s.AllowedClasses.Add("highlight-envelope-info-1");
s.AllowedClasses.Add("highlight-envelope-info-2");
});
// Register the FlagIconCssClass instance as a singleton