Replies: 1 comment 9 replies
-
|
Assuming you're using the most current released version (7.1.542), something like this works: services.AddSingleton<Ganss.XSS.IHtmlSanitizer, Ganss.XSS.HtmlSanitizer>(m =>
{
var options = new Ganss.XSS.HtmlSanitizerOptions
{
AllowedTags = Ganss.XSS.HtmlSanitizer.DefaultAllowedTags,
AllowedAttributes = Gans.XSS.HtmlSanitizer.DefaultAllowedAttributes
};
options.AllowedTags.Remove("a");
options.AllowedAttributes.Remove("href");
var sanitizer = new Ganss.XSS.HtmlSanitizer(options);
return sanitizer;
});Note that the |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
I can not get this to work. I am trying to inject the default options and only remove certain tags and attributes. For example, I am OK with all the default attributes except "href" how do I remove it globally through startup.cs?
This is not removing the "a" and "href" from the list of attributes and tags.
I simply want to configure it in startup.cs and use the same options globally across my application.
Can someone please help
Beta Was this translation helpful? Give feedback.
All reactions