From 2dcf69e9af13dcee71051f839dbe53928f31f433 Mon Sep 17 00:00:00 2001 From: Hasan-Zayni Date: Sat, 14 Nov 2026 11:51:34 +0300 Subject: [PATCH] svg: opening a file leaves out an embedded image over a budget instead of refusing the file Since the craft-svg migration, parse_with failed the whole drawing whenever the resolver refused an embedded image for the raster-pixel or byte/nesting budget. The resolver already leaves such an image out of the tree, so the drawing can still open, as it did before. The bounded smart-object path keeps refusing. Fixes three tests in photocraft-io --test it: embedded_png_with_a_huge_claimed_size_is_not_decoded, gzip_compressed_embedded_svg_decompresses_once_with_a_size_cap, an_embedded_svg_gets_only_the_nesting_depth_the_drawing_left. Co-Authored-By: Claude Sonnet 5.5 --- crates/io/src/svg.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/io/src/svg.rs b/crates/io/src/svg.rs index 62aac29008..bee08d1372 100644 --- a/crates/io/src/svg.rs +++ b/crates/io/src/svg.rs @@ -448,13 +448,9 @@ fn parse_with(bytes: &[u8], fonts: fn() -> Arc) -> Resul let opt = options_with_isolation(fontdb, MAX_XML_DEPTH.saturating_sub(depth), isolated, Arc::clone(&image_resolver)); let tree = guarded_parse(|| craft_svg::tree::parse_text(text, &tree_limits(MAX_XML_DEPTH, MAX_RASTER_PIXELS), &opt))?; let tree = tree.map_err(svg_parse_error)?; - let usage = image_resolver.usage(); - if usage.raster_limit_images > 0 { - return Err(IoError::Svg("embedded SVG raster images exceed the decoded pixel budget".into())); - } - if usage.svg_limit_images > 0 { - return Err(IoError::Svg("embedded SVG images exceed the byte or nesting budget".into())); - } + // An embedded image over a budget was refused by the resolver and is left out of the + // tree, so the rest of the drawing still opens (as before the craft-svg migration). + // Only the bounded smart-object path refuses the whole drawing for it. Ok(Parsed { tree, fontless_text }) }) .map_err(IoError::from)