-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support astral symbols in encodeForHTMLAttribute
#8
Comments
Interesting - is there a security concern for Astral symbols - that is, can an astral be decoded to a javascript control character when not using unicode? |
You mean, when not using UTF-8? Not as far as I know, but it’s safest to escape them anyway. |
Note that it's also broken when using the literal astral characters:
|
@stuartf Of course, since |
I get that escaping the characters is safer, but wouldn't it be a workable solution to do something like stuartf@6d0542e |
That doesn’t just ignore astral symbols, but also lone surrogates. But since you can’t encode those in HTML anyhow, I guess that’s fine in this case. |
If you see value if adding the encoding for astral symbols I'd be more than happy to take a look at a patch and merge into master |
@chrisisbeef does that mean my above patch would or wouldn't work for you as it doesn't encode the astrals, it just ignores them and the lone surrogates? If you do want them encoded, would it be ok if the patch depended on the https://github.com/mathiasbynens/he library mentioned above (it is MIT licensed). |
Testing on http://rawgithub.com/chrisisbeef/jquery-encoder/master/site/index.html shows that invalid/incorrect HTML escape sequences are generated for astral symbols:
A robust library for escaping/encoding text for use in HTML (or decoding it) is he. Feel free to use it as a dependency for this project.
The text was updated successfully, but these errors were encountered: