Revert "Merge pull request #8635 from storytold/fix/ase-cap"

This reverts commit fc2a525ee1, reversing
changes made to bab45a99f3.
This commit is contained in:
bflatastic
2026-11-19 08:21:29 +07:00
parent fc2a525ee1
commit 6d8674bde8
2 changed files with 3 additions and 16 deletions
+1 -15
View File
@@ -114,10 +114,6 @@ fn swatches_from_cms(list: Vec<PaletteSwatch>) -> Vec<Swatch> {
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<Vec<u8>, 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::<usize>();
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())
+2 -1
View File
@@ -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() {