Skip to content

Invalid value handling#449

Closed
vladinator1000 wants to merge 3 commits intoparcel-bundler:masterfrom
vladinator1000:input-validation
Closed

Invalid value handling#449
vladinator1000 wants to merge 3 commits intoparcel-bundler:masterfrom
vladinator1000:input-validation

Conversation

@vladinator1000
Copy link

@vladinator1000 vladinator1000 commented Mar 22, 2023

We should handle errors when parsing a value with a missing closing brace:

.corrupt {
  color: hsla(120, 62.32%;
}

Related issue: #427

This aims to replicate this browser behavior
image

}
"#;

let parsed = StyleSheet::parse(input, ParserOptions::default()).unwrap_err();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test currently fails, because the parsing result is Ok when it should be an error.

---- value_missing_closing_brace stdout ----
thread 'value_missing_closing_brace' panicked at 'called `Result::unwrap_err()` on an `Ok` value: StyleSheet { rules: CssRuleList([Style(StyleRule { selectors: SelectorList([Selector(.corrupt, specificity = 0x400)]), vendor_prefix: (empty), declarations: DeclarationBlock { important_declarations: [], declarations: [Unparsed(UnparsedProperty { property_id: Color, value: TokenList([Function(Function { name: Ident("hsla"), arguments: TokenList([Token(Number { has_sign: false, value: 120.0, int_value: Some(120) }), Token(Comma), Token(Percentage { has_sign: false, unit_value: 0.6232, int_value: None }), Token(Semicolon), Token(WhiteSpace(" ")), Token(CloseCurlyBracket)]) })]) })] }, rules: CssRuleList([]), loc: Location { source_index: 0, line: 1, column: 5 } })]), sources: [""], source_map_urls: [None], options: ParserOptions { filename: "", nesting: false, custom_media: false, css_modules: None, source_index: 0, error_recovery: false, warnings: None } }', tests/test_invalid_input.rs:15:67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant