Skip to content

Commit

Permalink
Error on invalid tokens
Browse files Browse the repository at this point in the history
Fixes #427. Closes #449
  • Loading branch information
devongovett committed Apr 18, 2023
1 parent 48841f7 commit 68e3dbd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Expand Up @@ -23770,6 +23770,18 @@ mod tests {
)
}

#[test]
fn test_invalid() {
error_test(
".a{color: hsla(120, 62.32%;}",
ParserError::UnexpectedToken(Token::CloseCurlyBracket),
);
error_test(
".a{--foo: url(foo\\) b\\)ar)}",
ParserError::UnexpectedToken(Token::BadUrl("foo\\) b\\)ar".into())),
);
}

#[test]
fn test_container_queries() {
// with name
Expand Down
6 changes: 6 additions & 0 deletions src/properties/custom.rs
Expand Up @@ -430,6 +430,12 @@ impl<'i> TokenList<'i> {
last_is_delim = false;
last_is_whitespace = false;
}
Ok(token) if token.is_parse_error() => {
return Err(ParseError {
kind: ParseErrorKind::Basic(BasicParseErrorKind::UnexpectedToken(token.clone())),
location: state.source_location(),
})
}
Ok(token) => {
last_is_delim = matches!(token, cssparser::Token::Delim(_) | cssparser::Token::Comma);

Expand Down

0 comments on commit 68e3dbd

Please sign in to comment.