EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge #1945: Reject non-hex characters such as '+' in Rgba::from_hex (@Silvertree2010)
aiongg9384ab7a47c7
diff --cc crates/color/src/lib.rsindex 4a280627d,a8957bcb9..2a0dfc50e--- a/crates/color/src/lib.rs+++ b/crates/color/src/lib.rs@@@ -262,14 -268,14 +268,22 @@@ mod testsassert!(r > 0.99 && g < 0.01 && b < 0.01, "{r} {g} {b}");}+ #[test]+ fn hue_stays_below_one_for_tiny_blue() {+ let (h, _, _) = rgb_to_hsv(1.0, 0.0, 1e-9);+ assert!((0.0..1.0).contains(&h), "rgb_to_hsv hue {h} not in 0..1");+ let (h, _, _) = rgb_to_hsl(1.0, 0.0, 1e-9);+ assert!((0.0..1.0).contains(&h), "rgb_to_hsl hue {h} not in 0..1");+ }++ #[test]+ fn rejects_signed_hex_pairs() {+ assert!(Rgba::from_hex("#+1+2+3").is_none());+ assert!(Rgba::from_hex("#1+2+3+").is_none());+ assert!(Rgba::from_hex("#ff00+0ff").is_none());+ assert!(Rgba::from_hex("#a1B2c3").is_some());+ }+#[test]fn srgb_roundtrip() {for i in 0..=100 {