Skip to content

Commit

Permalink
Added AllowCssCustomProperties and AllowDataAttributes to the options.
Browse files Browse the repository at this point in the history
  • Loading branch information
leniency committed Jul 26, 2024
1 parent 83d115c commit 28c725c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/HtmlSanitizer/HtmlSanitizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public HtmlSanitizer(HtmlSanitizerOptions options)
AllowedClasses = new HashSet<string>(options.AllowedCssClasses, StringComparer.OrdinalIgnoreCase);
AllowedCssProperties = new HashSet<string>(options.AllowedCssProperties, StringComparer.OrdinalIgnoreCase);
AllowedAtRules = new HashSet<CssRuleType>(options.AllowedAtRules);
AllowCssCustomProperties = options.AllowCssCustomProperties;
AllowDataAttributes = options.AllowDataAttributes;
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/HtmlSanitizer/HtmlSanitizerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@ public class HtmlSanitizerOptions
/// Gets or sets the HTML attributes that can contain a URI such as "href".
/// </summary>
public ISet<string> UriAttributes { get; set; } = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

/// <summary>
/// Allow all custom CSS properties (variables) prefixed with <c>--</c>.
/// </summary>
public bool AllowCssCustomProperties { get; set; }

/// <summary>
/// Allow all HTML5 data attributes; the attributes prefixed with <c>data-</c>.
/// </summary>
public bool AllowDataAttributes { get; set; }
}
}

0 comments on commit 28c725c

Please sign in to comment.