From b832ae5a95e75b92edbaeea47bdceb956bc4f432 Mon Sep 17 00:00:00 2001 From: xenofem Date: Wed, 27 Apr 2022 20:31:12 -0400 Subject: [PATCH] zip: set bit flag for UTF-8 filenames, bump minimum zip version to 6.3 --- src/zip.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/zip.rs b/src/zip.rs index ee112d0..16a1fcf 100644 --- a/src/zip.rs +++ b/src/zip.rs @@ -87,9 +87,10 @@ impl UploadedFile { /// through "Extra field length". fn shared_header_fields(&self, hash: Option) -> Vec { let mut fields = vec![ - 45, 0, // Minimum version required to extract: 4.5 for ZIP64 extensions - 0b00001000, 0, // General purpose bit flag: size and CRC-32 in data descriptor - 0, 0, // Compression method: none + 63, 0, // Minimum version required to extract: 6.3 for UTF-8 filenames + 0b00001000, // General purpose bit flag: bit 3 - size and CRC-32 in data descriptor + 0b00001000, // General purpose bit flag: bit 11 - UTF-8 filenames + 0, 0, // Compression method: none ]; append_value(&mut fields, fat_timestamp(self.modtime) as u64, 4); // Use 0s as a placeholder if the CRC-32 hash isn't known yet @@ -137,7 +138,7 @@ impl UploadedFile { fn central_directory_header(&self, local_header_offset: u64, hash: u32) -> Vec { let mut header = vec![ 0x50, 0x4b, 0x01, 0x02, // Central directory file header signature - 45, 3, // Made by a Unix system supporting version 4.5 + 63, 3, // Made by a Unix system supporting version 6.3 ]; header.append(&mut self.shared_header_fields(Some(hash))); append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes @@ -168,8 +169,8 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec { ]; append_0(&mut eocd, 7); // pad out the rest of the size field eocd.append(&mut vec![ - 45, 3, // Made by a Unix system supporting version 4.5 - 45, 0, // Minimum version 4.5 to extract + 63, 3, // Made by a Unix system supporting version 6.3 + 63, 0, // Minimum version 6.3 to extract ]); append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0 // Number of central directory records, on this disk and in total