From b122ba51dd96a93ffae18bc2fa539d19ad2ebcf1 Mon Sep 17 00:00:00 2001 From: kiwi4boy Date: Fri, 20 Nov 2026 02:23:13 -0500 Subject: [PATCH] ppt-binary: a PowerPoint 95 slide whose SlideAtom was cut short is lost too A stream cut just after the SlideAtom's header left an atom with no body, which counted as kept: the slide read blank and nothing was named lost. A slide is now kept only when its atom gives its id and its master's. --- crates/ppt-binary/src/ppt95.rs | 6 +++--- crates/ppt-binary/src/ppt95/tests.rs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/ppt-binary/src/ppt95.rs b/crates/ppt-binary/src/ppt95.rs index a8c2540db..ae5d33207 100644 --- a/crates/ppt-binary/src/ppt95.rs +++ b/crates/ppt-binary/src/ppt95.rs @@ -131,10 +131,10 @@ pub fn document(stream: &[u8]) -> Option> { } /// Whether a slide record holds what PowerPoint 95 writes first in every slide, its SlideAtom -/// (1007). One without it kept nothing (a file cut short just after the slide's header): it is left -/// out and named as lost. +/// (1007), whole enough to give the slide's id and its master's. One without it kept nothing (a +/// file cut short just after the slide's header, or the atom's): it is left out and named as lost. fn kept(slide: &Rec) -> bool { - slide.child(rt::SLIDE_ATOM).is_some() + slide.child(rt::SLIDE_ATOM).and_then(|a| a.u32(4)).is_some() } /// The slides a truncated or damaged file lost, by position ("slide 3"): those listed without their diff --git a/crates/ppt-binary/src/ppt95/tests.rs b/crates/ppt-binary/src/ppt95/tests.rs index 3d782f5a3..6588266ca 100644 --- a/crates/ppt-binary/src/ppt95/tests.rs +++ b/crates/ppt-binary/src/ppt95/tests.rs @@ -371,6 +371,11 @@ fn slides_the_count_says_are_missing_are_named() { let second = two.windows(one.len()).rposition(|w| w == one).unwrap(); let (p, lost) = crate::import_checked(&file_of(&two[..second + 16]), &AppDefaults).unwrap(); assert_eq!((p.slides.len(), lost), (1, vec!["slide 2".to_string()])); + // Cut just after its SlideAtom's header, or partway into the atom: still lost. + for cut in [32, 36] { + let (p, lost) = crate::import_checked(&file_of(&two[..second + cut]), &AppDefaults).unwrap(); + assert_eq!((p.slides.len(), lost), (1, vec!["slide 2".to_string()]), "cut at {cut}"); + } } /// Real PowerPoint 95 files, when `CRAFT_PPT95_SAMPLES` names a directory of them (they are not in