ignore non-ascii numeric characters in numbers

This commit is contained in:
ConnorSkees 2020-05-24 13:08:31 -04:00
parent c9e5bc89c4
commit b5c1fb2013
3 changed files with 7 additions and 2 deletions

View File

@ -124,7 +124,7 @@ pub(crate) fn eat_number<I: Iterator<Item = Token>>(
fn eat_whole_number<I: Iterator<Item = Token>>(toks: &mut PeekMoreIterator<I>, buf: &mut String) { fn eat_whole_number<I: Iterator<Item = Token>>(toks: &mut PeekMoreIterator<I>, buf: &mut String) {
while let Some(c) = toks.peek() { while let Some(c) = toks.peek() {
if !c.kind.is_numeric() { if !c.kind.is_ascii_digit() {
break; break;
} }
let tok = toks.next().unwrap(); let tok = toks.next().unwrap();

View File

@ -682,7 +682,7 @@ impl Value {
let unit = if let Some(tok) = toks.peek() { let unit = if let Some(tok) = toks.peek() {
let Token { kind, pos } = *tok; let Token { kind, pos } = *tok;
match kind { match kind {
'a'..='z' | 'A'..='Z' | '_' | '\\' => { 'a'..='z' | 'A'..='Z' | '_' | '\\' | '\u{7f}'..=std::char::MAX => {
let u = match eat_ident_no_interpolation(toks, true, pos) { let u = match eat_ident_no_interpolation(toks, true, pos) {
Ok(v) => v, Ok(v) => v,
Err(e) => return Some(Err(e)), Err(e) => return Some(Err(e)),

View File

@ -84,6 +84,11 @@ test!(
"a {\n color: unit(1\\9);\n}\n", "a {\n color: unit(1\\9);\n}\n",
"a {\n color: \"\\\\9 \";\n}\n" "a {\n color: \"\\\\9 \";\n}\n"
); );
test!(
non_ascii_numeric_interpreted_as_unit,
"a {\n color: 2߄;\n}\n",
"@charset \"UTF-8\";\na {\n color: 2߄;\n}"
);
error!( error!(
display_single_mul, display_single_mul,
"a {\n color: 1rem * 1px;\n}\n", "Error: 1rem*px isn't a valid CSS value." "a {\n color: 1rem * 1px;\n}\n", "Error: 1rem*px isn't a valid CSS value."