From 15b2b06a72047202acd04a971002670fdf705438 Mon Sep 17 00:00:00 2001 From: Mathias Zhang Date: Tue, 8 Jul 2025 23:00:34 +0800 Subject: [PATCH] fix(zip): normalize path separators for cross-platform ZIP compatibility --- src/archive/zip.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 4130beb..8478028 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -242,6 +242,8 @@ where FinalError::with_title("Zip requires that all directories names are valid UTF-8") .detail(format!("File at '{path:?}' has a non-UTF-8 name")) })?; + // ZIP format requires forward slashes as path separators, regardless of platform + let entry_name = entry_name.replace(std::path::MAIN_SEPARATOR, "/"); if metadata.is_dir() { writer.add_directory(entry_name, options)?; @@ -251,6 +253,8 @@ where FinalError::with_title("Zip requires that all directories names are valid UTF-8") .detail(format!("File at '{target_path:?}' has a non-UTF-8 name")) })?; + // ZIP format requires forward slashes as path separators, regardless of platform + let target_name = target_name.replace(std::path::MAIN_SEPARATOR, "/"); // This approach writes the symlink target path as the content of the symlink entry. // We detect symlinks during extraction by checking for the Unix symlink mode (0o120000) in the entry's permissions.