diff --git a/crates/color/src/palette_io.rs b/crates/color/src/palette_io.rs index 1709fb57c8..cb8e0b3950 100644 --- a/crates/color/src/palette_io.rs +++ b/crates/color/src/palette_io.rs @@ -114,10 +114,6 @@ fn swatches_from_cms(list: Vec) -> Vec { list.into_iter().map(|w| Swatch { name: w.name, paint: Paint::solid(color_from_cms(w.color)), global: w.global, spot: w.spot }).collect() } -/// The most colors and groups one swatch exchange file holds, read or written (craft-cms reads -/// as many). -const ASE_MAX_ENTRIES: usize = 100_000; - fn to_cms_palette(lib: &SwatchLibrary) -> Palette { Palette { name: lib.name.clone(), @@ -152,17 +148,7 @@ pub fn write(lib: &SwatchLibrary, format: PaletteFormat) -> Result, Stri serde_json::to_string_pretty(&file).unwrap_or_default() } PaletteFormat::Gpl => return cms_palette::write_palette(&to_cms_palette(lib), cms_palette::PaletteFormat::Gpl), - PaletteFormat::Ase => { - let p = to_cms_palette(lib); - // Counted here, so the message is VectorCraft's own and its translations apply. - let entries = p.swatches.len() + p.groups.iter().map(|g| 1 + g.swatches.len()).sum::(); - if entries > ASE_MAX_ENTRIES { - return Err(format!( - "VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries}" - )); - } - return cms_palette::write_palette(&p, cms_palette::PaletteFormat::Ase); - } + PaletteFormat::Ase => return cms_palette::write_palette(&to_cms_palette(lib), cms_palette::PaletteFormat::Ase), PaletteFormat::Css => write_css(lib, keep), }; Ok(text.into_bytes()) diff --git a/crates/color/src/palette_io/tests.rs b/crates/color/src/palette_io/tests.rs index 43f7ae79cc..0e6adb90ed 100644 --- a/crates/color/src/palette_io/tests.rs +++ b/crates/color/src/palette_io/tests.rs @@ -2,11 +2,12 @@ use super::*; use crate::{Gradient, GradientPaint, GradientStop}; use proptest::prelude::*; -// The swatch exchange file's signature and block types, which craft-cms keeps private. +// The swatch exchange file's signature, block types and entry cap, which craft-cms keeps private. const ASE_SIGNATURE: &[u8] = b"ASEF"; const ASE_GROUP_START: u16 = 0xC001; const ASE_GROUP_END: u16 = 0xC002; const ASE_COLOR: u16 = 0x0001; +const ASE_MAX_ENTRIES: usize = 100_000; #[test] fn gpl_blank_name_keeps_fallback() {