From 8eb962d37b8c1a017db871c1076a663e19a764bb Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Wed, 4 Nov 2026 13:52:22 +0100 Subject: [PATCH] engine: the shared-JBIG2 redaction test looks for the key itself This branch removes Document::jbig2_globals_ref, which #5910's test used. The test now counts streams whose dictionary holds JBIG2Globals in any spelling, which also covers the arrays and references the old helper didn't read. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 5d95486c32..fbe68e561b 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -10349,7 +10349,13 @@ fn redacting_an_optimized_jbig2_page_stores_the_rest_of_its_group_again() { assert_eq!(globals(&doc, images[2]), None, "the DeviceN page is coded alone"); pdfcraft_redact::apply(&mut doc, None).unwrap(); let saved = Document::open(Arc::new(write_full(&doc, &SaveOptions::default()).unwrap())).unwrap(); - let named = saved.scan_objects().filter(|(_, o)| matches!(&**o, Object::Stream(s) if saved.jbig2_globals_ref(s).is_some())).count(); + // Named in any spelling of its parameters: the stream's dictionary holds the key. + let names = |s: &Stream| { + let mut bytes = Vec::new(); + pdfcraft_cos::serialize(&Object::Dict(s.dict.clone()), &mut bytes); + bytes.windows(12).any(|w| w == b"JBIG2Globals") + }; + let named = saved.scan_objects().filter(|(_, o)| matches!(&**o, Object::Stream(s) if names(s))).count(); assert_eq!(named, 0, "no image names the dictionary, which left with them"); }