Skip to content

Commit 8f84448

Browse files
committed
Fix servo#133 <unicode-range> parsing corner case
Unexpected tokens after U+<integer> are not an error, just not part of the <unicode-range>.
1 parent a22151d commit 8f84448

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "cssparser"
4-
version = "0.12.1"
4+
version = "0.12.2"
55
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
66

77
description = "Rust implementation of CSS Syntax Level 3"

src/css-parsing-tests/urange.json

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
null
5656
],
5757

58+
"U+2 , U+???", [
59+
[2, 2],
60+
[0, 4095]
61+
],
5862

5963
"u+20-3F, u+3F-3F, u+3F-3E, U+0-110000, U+0-10FFFF, U+100000-2, U+1000000-2, U+10-200000", [
6064
[32, 63],

src/unicode_range.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,8 @@ fn concatenate_tokens(input: &mut Parser, remaining: &mut &mut [u8]) -> Result<(
8282
let int_value = positive_integer_with_plus_sign(value)?;
8383
write!(remaining, "{}", int_value)?;
8484

85+
let after_number = input.position();
8586
match input.next_including_whitespace() {
86-
// EOF here is fine
87-
Err(()) => {},
88-
8987
Ok(Token::Delim('?')) => {
9088
// If `remaining` is already full, `int_value` has too many digits
9189
// so we can use `result?` Rust syntax.
@@ -105,7 +103,7 @@ fn concatenate_tokens(input: &mut Parser, remaining: &mut &mut [u8]) -> Result<(
105103
write!(remaining, "{}", int_value)?
106104
}
107105

108-
_ => return Err(Error)
106+
_ => input.reset(after_number)
109107
}
110108
}
111109

0 commit comments

Comments
 (0)