mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(io): keep SVG drawings when embedded images exceed limits
This commit is contained in:
1 parent
c162cb6d63
commit
f974b6428c
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()));
|
||||
}
|
||||
// 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)
|
||||
|
||||
Reference in new issue
Block a user