don't say the zipfile was made on unix, it causes trouble with permissions

This commit is contained in:
xenofem 2022-04-27 00:28:26 -04:00
parent 92e7207c55
commit b84cb24ab9

View file

@ -129,8 +129,14 @@ impl UploadedFile {
fn central_directory_header(&self, local_header_offset: usize, hash: u32) -> Vec<u8> { fn central_directory_header(&self, local_header_offset: usize, hash: u32) -> Vec<u8> {
let mut header = vec![ let mut header = vec![
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature // Central directory file header signature
45, 3, // Made by a Unix system supporting version 4.5 0x50, 0x4b, 0x01, 0x02,
// Made by a "DOS" system supporting version 4.5 - if we
// say it's made by a Unix system, then unzip will expect
// it to have embedded Unix permission information, and
// will set all the files to mode 000 when that's not
// present :/
45, 0,
]; ];
header.append(&mut self.shared_header_fields(Some(hash))); header.append(&mut self.shared_header_fields(Some(hash)));
header.append(&mut vec![ header.append(&mut vec![
@ -165,7 +171,7 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec<u8> {
]; ];
append_0(&mut eocd, 7); // pad out the rest of the size field append_0(&mut eocd, 7); // pad out the rest of the size field
eocd.append(&mut vec![ eocd.append(&mut vec![
45, 3, // Made by a Unix system supporting version 4.5 45, 0, // Made by a "DOS" system supporting version 4.5, see above
45, 0, // Minimum version 4.5 to extract 45, 0, // Minimum version 4.5 to extract
]); ]);
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0 append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0