From 98807de6b22bb4bc89432ec8917fa8e404c7b8d6 Mon Sep 17 00:00:00 2001 From: oracola91 <118899664+oracola91@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:58:29 +0200 Subject: [PATCH] Remove Hidden Information keeps an unlink that was its only removal Unlinking images nothing draws ran before the check for an empty result, so a run where it was the only removal returned NothingToApply. The remove-hidden edit and the Action Wizard step then dropped the working copy, and the image stayed in the file. A run that unlinked anything now succeeds and asks for the full rewrite. --- crates/redact/src/sanitize.rs | 6 +++--- crates/redact/src/tests.rs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/redact/src/sanitize.rs b/crates/redact/src/sanitize.rs index 49cda651b6..92c4431337 100644 --- a/crates/redact/src/sanitize.rs +++ b/crates/redact/src/sanitize.rs @@ -672,9 +672,9 @@ pub fn remove_hidden(doc: &mut Document, which: &[Hidden]) -> Result>".to_vec(), + b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>".to_vec(), + b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 300 300] /Resources << /XObject << /Deleted 4 0 R >> >> >>".to_vec(), + gray_image(b"DELETEDIMAGEBYTES"), + ]); + assert_eq!(remove_hidden(&mut doc, &[Hidden::Metadata]), Ok(Vec::new())); + let bytes = write_full(&doc, &SaveOptions { object_streams: false, ..SaveOptions::default() }).unwrap(); + assert!(!bytes.windows(17).any(|w| w == b"DELETEDIMAGEBYTES"), "the deleted image survived the save"); +} + /// A name a pattern, a form, an appearance or a soft mask doesn't define is looked up in the /// page's resources, /Resources of its own or not: an image drawn only that way is still shown, /// so it stays. One no content names goes.