-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't allow invalid Unicode scalar values in char
#3866
Conversation
self.global( | ||
" | ||
function _assertChar(c) { | ||
if (typeof(c) === 'number' && (c >= 0x110000 || (c >= 0xD800 && c < 0xE000))) throw new Error(`expected a valid Unicode scalar value, found ${c}`); |
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 believe this should work, I also added a couple of tests for this as well.
tests/wasm/char.rs
Outdated
#[wasm_bindgen] | ||
pub fn rust_js_option_identity(c: Option<char>) -> Option<char> { | ||
js_option_identity(c) | ||
} |
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.
This doesn't seem to be used.
CI is currently broken because of rust-lang/rust#121932, which will be fixed tomorrow (hopefully) by rust-lang/rust#121933. |
This adds runtime checks for passing
char
from JS, which prevents invalid Unicode scalar values.Fixes #2269.