Replace surrogates in JS strings with U+FFFD instead of panicking.

Fix #6519.
See #6564.
This commit is contained in:
Simon Sapin 2015-07-11 03:03:17 +02:00
parent 52e857dd7b
commit 3f07f8e866

View file

@ -355,7 +355,9 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
let char_vec = unsafe {
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)
}
}