-
Notifications
You must be signed in to change notification settings - Fork 6
Improve HTML encode to handle single quotes #9
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
Conversation
|
Thanks! I thought single quotes didn't really need to be escaped. Did you find a case where it's an issue? |
ltrzesniewski
left a comment
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 are also other places in the code where HTML escaping is performed. Those would need to be updated as well.
|
So I coded this up late last night, hence the mistakes 😄 System.Text.Encodings.Web.HtmlEncoder.Default.Encode("foo's").ShouldBe("foo's");So copying this would lead to less surprises for future adopters. |
|
Ok, thanks for the explanation. I'll review this in more detail tonight, but I can already say that:
|
e4d37e8 to
181e40e
Compare
181e40e to
a0c9930
Compare
|
Thanks for catching those @ltrzesniewski, changes made |
| while (true) | ||
| { | ||
| var idx = valueSpan.IndexOfAny("&<>\""); | ||
| var idx = valueSpan.IndexOfAny("&<>\"`'"); |
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.
That backtick looks wrong
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.
I have no excuse this time 🤦♂️
|
I'm thinking this should also handle chars outside of the ASCII range, let me take a quick look at that too |
|
I don't think that's really required, everything handles Unicode now. |
|
I released this in v0.4.3 - thanks! 🙂 |
|
Amazing, thanks @ltrzesniewski |
This library is great! I found that it doesn't HTML escape single quotes, so here's a small PR...