mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
Bug 1490115
- Handle unaccompanied low surrogate pairs in the prefs parser. r=glandium
Currently they cause the `String::from_utf16()` call to return an error result, and then the subsequent `unwrap()` on that result aborts. --HG-- extra : rebase_source : 6be81d4d1e618444f762a1ba4e93b5ce648dd45b
This commit is contained in:
parent
eafdf2d611
commit
46c70d27ee
@ -600,8 +600,7 @@ impl<'t> Parser<'t> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns false if we hit EOF without closing the comment.
|
// Returns false if we hit EOF without closing the comment.
|
||||||
fn match_multi_line_comment(&mut self) -> bool
|
fn match_multi_line_comment(&mut self) -> bool {
|
||||||
{
|
|
||||||
loop {
|
loop {
|
||||||
match self.get_char() {
|
match self.get_char() {
|
||||||
b'*' => {
|
b'*' => {
|
||||||
@ -854,7 +853,7 @@ impl<'t> Parser<'t> {
|
|||||||
} else {
|
} else {
|
||||||
self.string_error_token(
|
self.string_error_token(
|
||||||
&mut token,
|
&mut token,
|
||||||
"invalid low surrogate value after high surrogate");
|
"invalid low surrogate after high surrogate");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -864,6 +863,11 @@ impl<'t> Parser<'t> {
|
|||||||
&mut token, "expected low surrogate after high surrogate");
|
&mut token, "expected low surrogate after high surrogate");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if 0xdc00 == (0xfc00 & value) {
|
||||||
|
// Unaccompanied low surrogate value.
|
||||||
|
self.string_error_token(
|
||||||
|
&mut token, "expected high surrogate before low surrogate");
|
||||||
|
continue;
|
||||||
} else if value == 0 {
|
} else if value == 0 {
|
||||||
self.string_error_token(&mut token, "\\u0000 is not allowed");
|
self.string_error_token(&mut token, "\\u0000 is not allowed");
|
||||||
continue;
|
continue;
|
||||||
|
@ -196,14 +196,24 @@ pref("int.ok", 0);
|
|||||||
"test:2: prefs parse error: expected low surrogate after high surrogate\n"
|
"test:2: prefs parse error: expected low surrogate after high surrogate\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// High surrogate followed by invalid low surrogate value.
|
// High surrogate followed by invalid low surrogate.
|
||||||
// (The string literal is broken in two so that MSVC doesn't complain about
|
// (The string literal is broken in two so that MSVC doesn't complain about
|
||||||
// an invalid universal-character-name.)
|
// an invalid universal-character-name.)
|
||||||
DEFAULT(R"(
|
DEFAULT(R"(
|
||||||
pref("string.bad-u-surrogate", "foo\)" R"(ud83c\u1234");
|
pref("string.bad-u-surrogate", "foo\)" R"(ud83c\u1234");
|
||||||
pref("int.ok", 0);
|
pref("int.ok", 0);
|
||||||
)",
|
)",
|
||||||
"test:2: prefs parse error: invalid low surrogate value after high surrogate\n"
|
"test:2: prefs parse error: invalid low surrogate after high surrogate\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Low surrogate not preceded by high surrogate.
|
||||||
|
// (The string literal is broken in two so that MSVC doesn't complain about
|
||||||
|
// an invalid universal-character-name.)
|
||||||
|
DEFAULT(R"(
|
||||||
|
pref("string.bad-u-surrogate", "foo\)" R"(udc00");
|
||||||
|
pref("int.ok", 0);
|
||||||
|
)",
|
||||||
|
"test:2: prefs parse error: expected high surrogate before low surrogate\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Unlike in JavaScript, \b, \f, \t, \v aren't allowed.
|
// Unlike in JavaScript, \b, \f, \t, \v aren't allowed.
|
||||||
|
Loading…
Reference in New Issue
Block a user