Merge pull request #1406

Find zip entries stored with backslash separators in pptx packages
This commit is contained in:
Brandon Thomas
2026-10-30 16:08:19 -04:00
+10 -1
View File
@@ -93,7 +93,8 @@ impl Package {
}
}
total = total.saturating_add(data.len() as u64);
parts.insert(name.to_ascii_lowercase(), (name, data));
// A name kept with `\` would reach code that splits paths on `/`.
parts.insert(norm(&name), (name.replace('\\', "/"), data));
}
Ok(Package { parts, ct_cache: std::sync::OnceLock::new() })
}
@@ -499,6 +500,14 @@ mod tests {
assert!(p.get("e").is_some());
}
#[test]
fn backslash_zip_entry_names_are_found() {
let z = zip_of(&[("PPT\\Slides\\Slide1.xml", 3)]);
let p = Package::open(&z).unwrap();
assert!(p.get("ppt/slides/slide1.xml").is_some());
assert_eq!(p.original_name("ppt/slides/slide1.xml"), Some("PPT/Slides/Slide1.xml"));
}
#[test]
fn xml_bytes_applies_the_xml_limit() {
let z = zip_of(&[("small.xml", 10)]);