Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cssparser"
version = "0.29.1"
version = "0.29.2"
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]

description = "Rust implementation of CSS Syntax Level 3"
Expand Down
7 changes: 4 additions & 3 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ where
{
let (red, green, blue, uses_commas) = match_ignore_ascii_case! { name,
"rgb" | "rgba" => parse_rgb_components_rgb(component_parser, arguments)?,
"hsl" | "hsla" => parse_hsl_hwb(component_parser, arguments, hsl_to_rgb)?,
"hwb" => parse_hsl_hwb(component_parser, arguments, hwb_to_rgb)?,
"hsl" | "hsla" => parse_hsl_hwb(component_parser, arguments, hsl_to_rgb, /* allow_comma = */ true)?,
"hwb" => parse_hsl_hwb(component_parser, arguments, hwb_to_rgb, /* allow_comma = */ false)?,
_ => return Err(arguments.new_unexpected_token_error(Token::Ident(name.to_owned().into()))),
};

Expand Down Expand Up @@ -633,6 +633,7 @@ fn parse_hsl_hwb<'i, 't, ComponentParser>(
component_parser: &ComponentParser,
arguments: &mut Parser<'i, 't>,
to_rgb: impl FnOnce(f32, f32, f32) -> (f32, f32, f32),
allow_comma: bool,
) -> Result<(u8, u8, u8, bool), ParseError<'i, ComponentParser::Error>>
where
ComponentParser: ColorComponentParser<'i>,
Expand All @@ -646,7 +647,7 @@ where
let hue = hue_normalized_degrees / 360.;

// Saturation and lightness are clamped to 0% ... 100%
let uses_commas = arguments.try_parse(|i| i.expect_comma()).is_ok();
let uses_commas = allow_comma && arguments.try_parse(|i| i.expect_comma()).is_ok();

let first_percentage = component_parser.parse_percentage(arguments)?.max(0.).min(1.);

Expand Down
3 changes: 2 additions & 1 deletion src/css-parsing-tests/color4_hwb.json
Original file line number Diff line number Diff line change
Expand Up @@ -7774,5 +7774,6 @@
"hwb(360deg 100% 100% / 0.2)", [128, 128, 128, 51],
"hwb(360 100% 100% / 0.2)", [128, 128, 128, 51],
"hwb(360deg 100% 100% / 1)", [128, 128, 128, 255],
"hwb(360 100% 100% / 1)", [128, 128, 128, 255]
"hwb(360 100% 100% / 1)", [128, 128, 128, 255],
"hwb(360, 100%, 100%)", null
]