diff --git a/Cargo.lock b/Cargo.lock
index d17a4cbb16..62ab5030f0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1434,7 +1434,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba62
[[package]]
name = "craft-dpx"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"thiserror 2.0.21",
]
@@ -1442,7 +1442,7 @@ dependencies = [
[[package]]
name = "craft-exr"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"serde_json",
]
@@ -1455,7 +1455,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=6e03f65bf45181db77ba62
[[package]]
name = "craft-gif"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
[[package]]
name = "craft-heif"
@@ -1500,7 +1500,7 @@ dependencies = [
[[package]]
name = "craft-kra"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1510,7 +1510,7 @@ dependencies = [
[[package]]
name = "craft-ora"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1542,7 +1542,7 @@ dependencies = [
[[package]]
name = "craft-pdn"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1565,7 +1565,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"encoding_rs",
"flate2",
@@ -1576,7 +1576,7 @@ dependencies = [
[[package]]
name = "craft-raster-codecs"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"rayon",
"thiserror 2.0.21",
@@ -1585,7 +1585,7 @@ dependencies = [
[[package]]
name = "craft-tga"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"thiserror 2.0.21",
]
@@ -1649,7 +1649,7 @@ dependencies = [
[[package]]
name = "craft-xcf"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1658,7 +1658,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
@@ -1667,7 +1667,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
-source = "git+https://github.com/storytold/craft-libs?rev=09dcbc225b95232998498a40ca56e24716571d53#09dcbc225b95232998498a40ca56e24716571d53"
+source = "git+https://github.com/storytold/craft-libs?rev=f92a91afa400883309aa46d8a3c0d0baa31c4f35#f92a91afa400883309aa46d8a3c0d0baa31c4f35"
dependencies = [
"flate2",
"thiserror 2.0.21",
diff --git a/Cargo.toml b/Cargo.toml
index 85d9a5b582..4c3b2152eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,7 @@ photocraft-raster = { path = "crates/raster" }
photocraft-doc = { path = "crates/doc" }
photocraft-ops = { path = "crates/ops" }
# PSD/PSB and the Photoshop resource files (ABR, ASL, ACO, ATN, ...): the shared reader and writer (craft-libs#875).
-craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
photocraft-codecs = { path = "crates/codecs" }
photocraft-raw = { path = "crates/raw" }
photocraft-affinity = { path = "crates/affinity" }
@@ -42,21 +42,21 @@ photocraft-ipp = { path = "crates/ipp" }
# external
# Krita, OpenRaster and GIMP XCF: the format code (archives, node trees, tiles); the mapping onto
# documents stays in crates/io (craft-libs#928, #935, #960).
-craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
-craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
-craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
+craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
+craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
# Paint.NET PDN3 and its MS-NRBF serialization (craft-libs#968).
-craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
# DDS, DICOM, FITS, IFF/ILBM, PCX, PNM and XPM: the shared decoders and encoders (craft-libs#880).
# DPX and Cineon frames (craft-libs#887); the mapping onto images stays in crates/codecs.
-craft-dpx = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-dpx = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
# The Targa writer (craft-libs#892).
-craft-tga = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-tga = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
# GIF blocks without decoding: the first frame's colour table, the frame walk (craft-libs#939).
-craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
# OpenEXR channel naming and Cryptomatte IDs, manifests and streams (craft-libs#929).
-craft-exr = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
-craft-raster-codecs = { git = "https://github.com/storytold/craft-libs", rev = "09dcbc225b95232998498a40ca56e24716571d53" }
+craft-exr = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
+craft-raster-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f92a91afa400883309aa46d8a3c0d0baa31c4f35" }
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "6e03f65bf45181db77ba6229716e6624db9eb25b" }
# HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784).
craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "081078bb1b44aeedfa5bef3d4f13d978dc77510a" }
diff --git a/crates/cms/src/synth.rs b/crates/cms/src/synth.rs
index 390e509dce..c86bedc9bd 100644
--- a/crates/cms/src/synth.rs
+++ b/crates/cms/src/synth.rs
@@ -119,7 +119,7 @@ impl CmykModel {
(v + 4.0 * self.tvi[i] * v * (1.0 - v)).clamp(0.0, 1.0)
});
let mut s = [0.0; 3];
- for m in 0..16 {
+ for (m, prim) in self.prim_n.iter().enumerate() {
let mut w = 1.0;
for (i, ai) in a.iter().enumerate() {
w *= if m & (1 << i) != 0 { *ai } else { 1.0 - ai };
@@ -127,7 +127,7 @@ impl CmykModel {
if w == 0.0 {
continue;
}
- for (acc, p) in s.iter_mut().zip(&self.prim_n[m]) {
+ for (acc, p) in s.iter_mut().zip(prim) {
*acc += w * p;
}
}
diff --git a/crates/io/src/kra/tests.rs b/crates/io/src/kra/tests.rs
index 3a0964e85a..638d0e232a 100644
--- a/crates/io/src/kra/tests.rs
+++ b/crates/io/src/kra/tests.rs
@@ -211,11 +211,11 @@ fn deeply_nested_maindoc_is_an_error_not_a_stack_overflow() {
let entity = format!("]>&e;");
// A quoted `?>` in the XML declaration must not hide the DOCTYPE behind it.
let declared = format!("\"?>{entity}");
- // The nesting is refused by its depth; an internal subset is refused outright (craft-kra).
- for (xml, why) in [(direct, Some("nest")), (entity, None), (declared, None)] {
+ // The nesting is refused by its depth; entity-based forms must also fail safely.
+ for (xml, expected) in [(direct, Some("nest")), (entity, None), (declared, None)] {
let bytes = archive(&xml, &[]);
let e = std::thread::Builder::new().stack_size(512 * 1024).spawn(move || crate::import("deep.kra", &bytes).err()).unwrap().join().unwrap();
- assert!(matches!(&e, Some(IoError::Kra(m)) if why.is_none_or(|w| m.contains(w))), "{why:?}: {e:?}");
+ assert!(matches!(&e, Some(IoError::Kra(m)) if expected.is_none_or(|why| m.contains(why))), "{expected:?}: {e:?}");
}
}
diff --git a/crates/io/src/pdn.rs b/crates/io/src/pdn.rs
index 5facf3288b..22ee521d7f 100644
--- a/crates/io/src/pdn.rs
+++ b/crates/io/src/pdn.rs
@@ -62,17 +62,12 @@ pub(super) fn import(name: &str, bytes: &[u8], ctl: &Interrupt<'_>) -> Result Result<()> {
let mut surface = Surface::new(PixelFormat::RGBA8);
let mut row = Vec::with_capacity(width * 4);
for (y, src) in s.rows().enumerate() {
if ctl.check().is_err() {
- failed = Some(IoError::Cancelled);
- return;
+ return Err(IoError::Cancelled);
}
row.clear();
row.extend_from_slice(src);
@@ -83,11 +78,12 @@ pub(super) fn import(name: &str, bytes: &[u8], ctl: &Interrupt<'_>) -> Result pdn_err(error),
+ craft_pdn::ReadSurfacesError::Callback(error) => error,
+ })?;
let mut document = Document::new(name, Size::new(w, h), ColorMode::Rgb, SampleType::U8);
for l in &doc.layers {
let mut layer = Layer::raster(l.name.clone(), PixelFormat::RGBA8);
diff --git a/crates/io/src/xcf.rs b/crates/io/src/xcf.rs
index 1e401dc186..462a0f2975 100644
--- a/crates/io/src/xcf.rs
+++ b/crates/io/src/xcf.rs
@@ -153,7 +153,8 @@ fn write_pixels(surface: &mut Surface, px: &Pixels, x: i32, y: i32, budget: &mut
/// Imports an XCF file (already inflated when it was gzipped).
pub(crate) fn import(name: &str, bytes: &[u8], ctl: &Interrupt<'_>) -> Result {
- let xcf = Xcf::parse(bytes).map_err(xcf_err)?;
+ let keep_going = || ctl.check().is_ok();
+ let xcf = Xcf::parse_with(bytes, &keep_going).map_err(xcf_err)?;
let info = xcf.image();
let version = info.version;
let mut warnings = Warnings::default();
@@ -208,7 +209,6 @@ pub(crate) fn import(name: &str, bytes: &[u8], ctl: &Interrupt<'_>) -> Result= 1;
+
+ let result = super::import("cancel.xcf", &bytes, &Interrupt::cancel_only(&cancel));
+
+ assert!(matches!(result, Err(IoError::Cancelled)));
+ assert_eq!(checks.load(Ordering::Relaxed), 2, "cancellation stops before parsing the second layer");
+}
+
#[test]
fn every_truncation_errors_never_panics() {
let mut img = TestImage::rgb8(20, 20);
diff --git a/docs/kra.md b/docs/kra.md
index 6b893e8ce6..3ad4fc18f2 100644
--- a/docs/kra.md
+++ b/docs/kra.md
@@ -41,12 +41,14 @@ children (checked against Krita's merged image).
## Limits and safety
-The reader uses the bounded ZIP reader of `photocraft-format` (no ZIP64, CRC-checked), parses
-`maindoc.xml` with `roxmltree` (32 MiB cap; the DTD is declared by public id and not fetched),
-and decodes tiles with a bounds-checked LZF decoder that must produce exactly one tile. Tiles
-are at most 1024 px a side; canvases at most 300,000 px a side and 1 GiB of decoded pixels;
-8,192 nodes; nesting at most `MAX_GROUP_DEPTH`. Version 1 tile files (Krita 1.x) are refused.
-Malformed archives, XML, numbers, tile headers and tile data return errors; truncated and
+The shared `craft-kra` reader uses `craft-zip` for the archive (including ZIP64 directories,
+CRC-checked entry reads, and at most 100,000 entries) and `craft-xml` for `maindoc.xml`. The XML
+has a 32 MiB input limit and 512-level nesting limit; Krita's public DTD is not fetched, and an
+internal DTD subset is refused. A layer tile file may inflate to at most 1 GiB, and an ICC profile
+to 16 MiB. The app decodes tiles with a bounds-checked LZF decoder that must produce exactly one
+tile. Tiles are at most 1024 px a side; canvases at most 300,000 px a side and 1 GiB of decoded
+pixels; 8,192 nodes; nesting at most `MAX_GROUP_DEPTH`. Version 1 tile files (Krita 1.x) are
+refused. Malformed archives, XML, numbers, tile headers and tile data return errors; truncated and
corrupted files are covered by tests.
## Verification
diff --git a/docs/ora.md b/docs/ora.md
index d21fa9d3fc..72ef711bf1 100644
--- a/docs/ora.md
+++ b/docs/ora.md
@@ -49,12 +49,13 @@ Hard Mix open as Photoshop's Soft Light and Hard Mix, which differ slightly, wit
## Limits and safety
-The reader takes the archive with the bounded ZIP reader of `photocraft-format` (no ZIP64,
-CRC-checked), parses `stack.xml` with `roxmltree` (16 MiB cap), and decodes each layer image
-through `photocraft-codecs` with size limits. Canvases are at most 300,000 px a side, at most
-8,192 layers and groups, nesting at most `MAX_GROUP_DEPTH` deep, and 1 GiB of decoded pixels in
-total. Malformed archives, XML, numbers and images return errors; truncated and corrupted files
-are covered by tests.
+The shared `craft-ora` reader and writer use `craft-zip` for the archive (including ZIP64
+directories and CRC-checked entry reads, with at most 100,000 entries) and `craft-xml` for
+`stack.xml`. The XML has a 16 MiB input limit and 512-level nesting limit. A layer image entry may
+inflate to at most 512 MiB; decoded pixels across the document are limited to 1 GiB. Canvases are
+at most 300,000 px a side, at most 8,192 layers and groups, and nesting at most
+`MAX_GROUP_DEPTH` deep. Malformed archives, XML, numbers and images return errors; truncated and
+corrupted files are covered by tests.
## Verification