mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
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 <[email protected]>
This commit is contained in:
1 parent
5b27ff6fe3
commit
2dcf69e9af
1 file changed
+3
-7
@@ -448,13 +448,9 @@ fn parse_with(bytes: &[u8], fonts: fn() -> Arc<usvg::fontdb::Database>) -> 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)
|
||||
|
||||
Reference in new issue
Block a user