mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Auto merge of #6595 - servo:replace-surrogates, r=pcwalton
Replace surrogates in JS strings with U+FFFD instead of panicking. Fix #6519. See #6564. r? @pcwalton <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6595) <!-- Reviewable:end -->
This commit is contained in:
commit
0f36eeab61
1 changed files with 3 additions and 1 deletions
|
@ -355,7 +355,9 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
|
||||||
let char_vec = unsafe {
|
let char_vec = unsafe {
|
||||||
slice::from_raw_parts(chars as *const u16, length as usize)
|
slice::from_raw_parts(chars as *const u16, length as usize)
|
||||||
};
|
};
|
||||||
String::from_utf16(char_vec).unwrap()
|
// This is a wilful spec violation.
|
||||||
|
// See https://github.com/servo/servo/issues/6564
|
||||||
|
String::from_utf16_lossy(char_vec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue