mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
fix(es/codegen): Fix panic due to \\ud
(#8346)
**Related issue:** - Closes #8345
This commit is contained in:
parent
6e63b95bac
commit
1891afa2ad
2
crates/swc/tests/fixture/issues-8xxx/8345/input/1.js
Normal file
2
crates/swc/tests/fixture/issues-8xxx/8345/input/1.js
Normal file
@ -0,0 +1,2 @@
|
||||
const data = '\\ud';
|
||||
console.log(data);
|
2
crates/swc/tests/fixture/issues-8xxx/8345/output/1.js
Normal file
2
crates/swc/tests/fixture/issues-8xxx/8345/output/1.js
Normal file
@ -0,0 +1,2 @@
|
||||
var data = "\\ud";
|
||||
console.log(data);
|
@ -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("\\\\");
|
||||
|
Loading…
Reference in New Issue
Block a user