Clamp colors to valid values when parsing config
Browse files at this commit07080a0431d86d64efed6fa557c2a02cb9041e93Parent: aa472231 changed file +4 -1
- niri-config/src/lib.rs +4 -1
niri-config/src/lib.rsmodified+4 -1
| @@ -2677,7 +2677,10 @@ impl FromStr for Color { | |||
| 2677 | type Err = miette::Error; | 2677 | type Err = miette::Error; |
| 2678 | 2678 | ||
| 2679 | fn from_str(s: &str) -> Result<Self, Self::Err> { | 2679 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 2680 | - let color = csscolorparser::parse(s).into_diagnostic()?.to_array(); | 2680 | + let color = csscolorparser::parse(s) |
| 2681 | + .into_diagnostic()? | ||
| 2682 | + .clamp() | ||
| 2683 | + .to_array(); | ||
| 2681 | Ok(Self::from_array_unpremul(color)) | 2684 | Ok(Self::from_array_unpremul(color)) |
| 2682 | } | 2685 | } |
| 2683 | } | 2686 | } |