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.
This commit is contained in:
kiwi4boy committed 2026-11-20 02:23:13 -05:00
1 parent f09e70f281
commit b122ba51dd
2 files changed
+8 -3

No files matched your search

+3 -3
View File
@@ -131,10 +131,10 @@ pub fn document(stream: &[u8]) -> Option<Rec<'_>> {
}
/// 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
+5
View File
@@ -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