fix(io): keep SVG drawings when embedded images exceed limits

This commit is contained in:
Dylan M. Taylor committed 2026-11-15 06:08:00 +00:00
1 parent c162cb6d63
commit f974b6428c
1 file changed
+3 -7
+3 -7
View File
@@ -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()));
}
// The resolver leaves an embedded image out of the tree when it exceeds its
// byte, nesting, or pixel budget. Keep the rest of the drawing usable; strict
// bounded preview rendering checks these refusals separately.
Ok(Parsed { tree, fontless_text })
})
.map_err(IoError::from)