From f275acf1d279061074f089cb0049c8641b0495ff Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Tue, 14 May 2024 13:25:15 -0700 Subject: [PATCH] chore: Move path join into platform-independent code --- src/read.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/read.rs b/src/read.rs index 16bb37870..ad0a38050 100644 --- a/src/read.rs +++ b/src/read.rs @@ -13,7 +13,7 @@ use crate::types::{AesMode, AesVendorVersion, DateTime, System, ZipFileData}; use crate::zipcrypto::{ZipCryptoReader, ZipCryptoReaderValid, ZipCryptoValidator}; use indexmap::IndexMap; use std::borrow::Cow; -use std::ffi::OsStr; +use std::ffi::{OsStr, OsString}; use std::fs::create_dir_all; use std::io::{self, copy, prelude::*, sink}; use std::ops::Deref; @@ -689,16 +689,13 @@ impl ZipArchive { if file.is_symlink() && (cfg!(unix) || cfg!(windows)) { let mut target = Vec::with_capacity(file.size() as usize); file.read_exact(&mut target)?; + let target_path: PathBuf = directory.as_ref().join(OsString::try_from(target)?); #[cfg(unix)] { - use std::os::unix::ffi::OsStrExt; - let target_path: PathBuf = - directory.as_ref().join(OsStr::from_bytes(&target)); std::os::unix::fs::symlink(target_path, outpath.as_path())?; } #[cfg(windows)] { - let target_path: PathBuf = directory.as_ref().join(OsStr::from_vec(target)); if target_path.is_dir() { std::os::windows::fs::symlink_dir(target_path, outpath.as_path())?; } else {