fix(es/codegen): Fix panic due to \\ud (#8346)

**Related issue:**

 - Closes #8345
This commit is contained in:
Donny/강동윤 2023-11-27 10:54:45 +09:00 committed by GitHub
parent 6e63b95bac
commit 1891afa2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -0,0 +1,2 @@
const data = '\\ud';
console.log(data);

View File

@ -0,0 +1,2 @@
var data = "\\ud";
console.log(data);

View File

@ -3916,9 +3916,9 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String {
2..6
};
let val_str = &inner_buf[range];
if is_valid {
let val_str = &inner_buf[range];
let v = u32::from_str_radix(val_str, 16).unwrap_or_else(|err| {
unreachable!(
"failed to parse {} as a hex value: {:?}",
@ -3939,6 +3939,8 @@ fn get_quoted_utf16(v: &str, ascii_only: bool, target: EsVersion) -> String {
} else {
buf.push_str("\\\\");
}
} else {
buf.push_str("\\\\")
}
} else if is_curly {
buf.push_str("\\\\");