From 048ab562b294767ee95e933e18324ea342f32156 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 16 Feb 2020 15:34:21 -0500 Subject: [PATCH] more bounds checking --- src/builtin/color/hsl.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index 3501875..8575890 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -100,7 +100,7 @@ pub(crate) fn register(f: &mut BTreeMap) { v => return Err(format!("$color: {} is not a color.", v).into()), }; let amount = match arg!(args, 1, "amount").eval() { - Value::Dimension(n, _) => n / Number::from(100), + Value::Dimension(n, u) => bound!("amount", n, u, 0, 100) / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into()) }; Ok(Value::Color(color.darken(amount))) @@ -112,7 +112,7 @@ pub(crate) fn register(f: &mut BTreeMap) { v => return Err(format!("$color: {} is not a color.", v).into()), }; let amount = match arg!(args, 1, "amount").eval() { - Value::Dimension(n, _) => n / Number::from(100), + Value::Dimension(n, u) => bound!("amount", n, u, 0, 100) / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into()) }; Ok(Value::Color(color.saturate(amount))) @@ -124,7 +124,7 @@ pub(crate) fn register(f: &mut BTreeMap) { v => return Err(format!("$color: {} is not a color.", v).into()), }; let amount = match arg!(args, 1, "amount").eval() { - Value::Dimension(n, _) => n / Number::from(100), + Value::Dimension(n, u) => bound!("amount", n, u, 0, 100) / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into()) }; Ok(Value::Color(color.desaturate(amount)))