-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject attributes to an element while scrubbing #96
Comments
There isn't anything built in, but you could probably do that by subscribing to the Since HtmlSanitizer uses the AngleSharp library for parsing HTML, you could also just use it directly on the sanitized markup. |
Here's how you could do this using the sanitizer.PostProcessNode += (s, e) => (e.Node as IHtmlAnchorElement)?.SetAttribute("target", "_blank"); |
Perfect! This fixes my use case as well -- securing |
Nice example. I would think that adding "nofollow" to anchor tags would be a very common use case. I suggest adding that as an example in the wiki. |
@hammond13 🆗, I've added example 5 to the wiki. |
To anyone who stumbled across this, other rels which may be of interest include As well as |
is there a way that while scrubbing, the sanitizer can inject any attribute to an element. Such as while scrubbing anchor tags , I want to add target="_blank" to every anchor tag encountered by sanitizer?
The text was updated successfully, but these errors were encountered: