From c470ed170dcb7aaaad7ce6172ca4e9b68dd1a7cd Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Thu, 19 Nov 2026 23:46:01 -0500 Subject: [PATCH] hayro-interpret: restore FormXObject RESOURCES presence check and Indexed image recovery in x_object.rs (#2497) * hayro-interpret: port remaining pdfcraft resource-scope, indexed-image, and text-clip patches * hayro-interpret: keep craft-libs resource-scope and text contracts; retain x_object.rs fixes --- vendor/hayro-interpret/src/x_object.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vendor/hayro-interpret/src/x_object.rs b/vendor/hayro-interpret/src/x_object.rs index a772233f2..e12767400 100644 --- a/vendor/hayro-interpret/src/x_object.rs +++ b/vendor/hayro-interpret/src/x_object.rs @@ -83,7 +83,10 @@ impl<'a> FormXObject<'a> { // PdfCraft patch: see `context::MAX_PAGE_CONTENT`. let decoded = crate::context::decode_content(stream)?; - let resources = dict.get::>(RESOURCES); + // PdfCraft patch: retain absence; present malformed dictionaries stay local-empty. + let resources = dict + .contains_key(RESOURCES) + .then(|| dict.get::>(RESOURCES).unwrap_or_default()); let matrix = Affine::new( dict.get::<[f64; 6]>(MATRIX) @@ -611,9 +614,14 @@ impl<'a> ImageXObject<'a> { default_space = Some(key); Some(space) } else { + // PdfCraft patch (80): an Indexed space given in place whose `hival` has no + // reading cannot be built and falls back below, as upstream; it is reported. + malformed_indexed = cs_obj + .as_ref() + .is_some_and(crate::color::has_unusable_hival); cs_obj .clone() - .and_then(|c| ColorSpace::new(c, cache)) + .and_then(|c| ColorSpace::new_allowing_tableless(c, cache)) // Inline images can also refer to color spaces by name. .or_else(|| { cs_obj