-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add HtmlSanitizerOptions #359
Conversation
Codecov Report
@@ Coverage Diff @@
## master #359 +/- ##
==========================================
+ Coverage 94.32% 94.44% +0.11%
==========================================
Files 4 5 +1
Lines 811 828 +17
Branches 85 85
==========================================
+ Hits 765 782 +17
Misses 34 34
Partials 12 12
Continue to review full report at Codecov.
|
/// <summary> | ||
/// Gets or sets the allowed tag names such as "a" and "div". | ||
/// </summary> | ||
public ISet<string> AllowedTags { get; set; } = new HashSet<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these have private setters? Also, they should be initialized with StringComparer.OrdinalIgnoreCase
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I would want public setters because then I can easily assign a set to the properties using object initializer syntax. Without a setter, I would have to loop over a set and append each item in the set using the Add
method.
Yes, it should probably be initialized with StringComparer.OrdinalIgnoreCase
if we want it to be case-insensitive, which we probably do want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use object and collection initializer syntax even if the setter is private. Collection initializer syntax works with the Add()
method so you can do this:
public class SetTest
{
public HashSet<string> Set { get; private set; } = new HashSet<string>();
}
var s = new SetTest()
{
Set = { "a", "b" }
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. but you cannot assign from a predefined set like this:
public static class Presets
{
public static HashSet<string> Default { get; } = new HashSet<string>();
}
var s = new SetTest()
{
Set = Presets.Default
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, then how about making them init-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I like that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's this problem now. Not sure how to deal with it or if it's even worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems easier to just skip init
and just have public setters instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ok, I agree.
Thanks for starting this. I'm wondering how the |
I think you'd wind up with a simpler process for setting up a sanitizer if this just completely replaces the existing properties. |
I agree with @tiesont. |
Sorry, I had forgot about this. It builds now. |
Could you adapt the unit tests to cover the changes? |
Now it says there is coverage. |
No description provided.