From 587d6528b080fffd952a0d2f75148df7d02d9059 Mon Sep 17 00:00:00 2001 From: Grzegorz Martens Date: Mon, 9 Nov 2026 16:20:40 +0100 Subject: [PATCH] redact: the refusal test checks a copy with its filter by reference too In `a_shared_jbig2_dictionary_that_cant_leave_refuses_the_redaction`, the case of a copy of the dictionary whose `/Filter` is given by reference may end `Ok`, the image stored again without it. That branch checked only that the dictionary, object 9, left, and that its marker was nowhere in the file. But `assert_gone` can't decode the copy, object 10, with its filter by reference, and its bytes are Flate, so a run that never found the copy, and left it in the file, passed. The branch now checks that object 10 left too, through `reachable_objects`. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY --- crates/redact/src/tests.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/redact/src/tests.rs b/crates/redact/src/tests.rs index 9e60668483..2f554276b0 100644 --- a/crates/redact/src/tests.rs +++ b/crates/redact/src/tests.rs @@ -2204,7 +2204,10 @@ fn a_shared_jbig2_dictionary_that_cant_leave_refuses_the_redaction() { match apply(&mut doc, None) { Err(RedactError::SharedJbig2Globals(_)) => assert_eq!(drawn_samples(&doc, 0), drawn_samples(&before, 0), "{other}: nothing was redacted"), Ok(_) if through_reference => { - assert!(!pdfcraft_cos::reachable_objects(&doc).unwrap().contains(&9), "{other}: the dictionary stays"); + // Object 10 too, the copy or the reference to the dictionary: `assert_gone` can't + // decode the copy, its `/Filter` given by reference, nor see its bytes, which are Flate. + let kept = pdfcraft_cos::reachable_objects(&doc).unwrap(); + assert!(!kept.contains(&9) && !kept.contains(&10), "{other}: the dictionary or its copy stays"); assert_gone(&doc, b"LEAK_GLOBALS"); } result => panic!("{other}: {result:?}"),