From 017ab0cb241a58a5cf28205c18949f3748b587b3 Mon Sep 17 00:00:00 2001 From: David Shin Date: Fri, 17 Feb 2023 17:13:21 +0000 Subject: [PATCH] style: `linear()` easing function should not consider less than 2 linear stop arguments valid Latest spec no longer handles `linear() == linear` and `linear() == `. Differential Revision: https://phabricator.services.mozilla.com/D169955 --- components/style/values/specified/easing.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/style/values/specified/easing.rs b/components/style/values/specified/easing.rs index e10eb0b98b6..8021e3b7dcb 100644 --- a/components/style/values/specified/easing.rs +++ b/components/style/values/specified/easing.rs @@ -136,10 +136,8 @@ impl TimingFunction { if !linear_timing_function_enabled() { return Err(input.new_custom_error(StyleParseErrorKind::ExperimentalProperty)); } - if input.is_exhausted() { - return Ok(GenericTimingFunction::LinearFunction(LinearStops::default())); - } let mut result = vec![]; + // Closely follows `parse_comma_separated`, but can generate multiple entries for one comma-separated entry. loop { input.parse_until_before(Delimiter::Comma, |i| { let mut input_start = i.try_parse(|i| Percentage::parse(context, i)).ok(); @@ -175,6 +173,9 @@ impl TimingFunction { Ok(_) => unreachable!(), } } + if result.len() < 2 { + return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); + } Ok(GenericTimingFunction::LinearFunction(LinearStops::new( crate::OwnedSlice::from(result),