using AngleSharp.Css.Dom; using AngleSharp.Dom; using AngleSharp.Html.Dom; using System; using System.Collections.Generic; using System.ComponentModel; namespace Ganss.Xss; /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// public class PostProcessDomEventArgs(IHtmlDocument document) : EventArgs { /// /// Gets the document. /// /// /// The document. /// public IHtmlDocument Document { get; private set; } = document; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// public class PostProcessNodeEventArgs(IHtmlDocument document, INode node) : EventArgs { /// /// Gets the document. /// /// /// The document. /// public IHtmlDocument Document { get; private set; } = document; /// /// Gets the DOM node to be processed. /// /// /// The DOM node. /// public INode Node { get; private set; } = node; /// /// Gets the replacement nodes. Leave empty if no replacement should occur. /// /// /// The replacement nodes. /// public ICollection ReplacementNodes { get; private set; } = []; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The element to be removed. /// The reason why the tag will be removed. public class RemovingTagEventArgs(IElement tag, RemoveReason reason) : CancelEventArgs { /// /// Gets the tag to be removed. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; /// /// Gets the reason why the tag will be removed. /// /// /// The reason. /// public RemoveReason Reason { get; private set; } = reason; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The element containing the attribute. /// The attribute to be removed. /// The reason why the attribute will be removed. public class RemovingAttributeEventArgs(IElement tag, IAttr attribute, RemoveReason reason) : CancelEventArgs { /// /// Gets the tag containing the attribute to be removed. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; /// /// Gets the attribute to be removed. /// /// /// The attribute. /// public IAttr Attribute { get; private set; } = attribute; /// /// Gets the reason why the attribute will be removed. /// /// /// The reason. /// public RemoveReason Reason { get; private set; } = reason; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The element containing the attribute. /// The style to be removed. /// The reason why the attribute will be removed. public class RemovingStyleEventArgs(IElement tag, ICssProperty style, RemoveReason reason) : CancelEventArgs { /// /// Gets the tag containing the style to be removed. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; /// /// Gets the style to be removed. /// /// /// The style. /// public ICssProperty Style { get; private set; } = style; /// /// Gets the reason why the style will be removed. /// /// /// The reason. /// public RemoveReason Reason { get; private set; } = reason; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The element containing the attribute. /// The rule to be removed. public class RemovingAtRuleEventArgs(IElement tag, ICssRule rule) : CancelEventArgs { /// /// Gets the tag containing the at-rule to be removed. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; /// /// Gets the rule to be removed. /// /// /// The rule. /// public ICssRule Rule { get; private set; } = rule; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The comment to be removed. public class RemovingCommentEventArgs(IComment comment) : CancelEventArgs { /// /// Gets the comment node to be removed. /// /// /// The comment node. /// public IComment Comment { get; private set; } = comment; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The element containing the attribute. /// The CSS class to be removed. /// The reason why the attribute will be removed. public class RemovingCssClassEventArgs(IElement tag, string cssClass, RemoveReason reason) : CancelEventArgs { /// /// Gets the tag containing the CSS class to be removed. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; /// /// Gets the CSS class to be removed. /// /// /// The CSS class. /// public string CssClass { get; private set; } = cssClass; /// /// Gets the reason why the CSS class will be removed. /// /// /// The reason. /// public RemoveReason Reason { get; private set; } = reason; } /// /// Provides data for the event. /// /// /// Initializes a new instance of the class. /// /// The tag containing the URI being sanitized. /// The original URL. /// The sanitized URL. public class FilterUrlEventArgs(IElement tag, string originalUrl, string? sanitizedUrl = null) : EventArgs { /// /// Gets the original URL. /// /// /// The original URL. /// public string OriginalUrl { get; private set; } = originalUrl; /// /// Gets or sets the sanitized URL. /// /// /// The sanitized URL. If it is null, it will be removed. /// public string? SanitizedUrl { get; set; } = sanitizedUrl; /// /// Gets the tag containing the URI being sanitized. /// /// /// The tag. /// public IElement Tag { get; private set; } = tag; }