Skip to content

Commit

Permalink
Fix Windows CI: avoid UNC parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ncihnegn committed Sep 12, 2022
1 parent f4f439c commit c0ffc46
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/entry.rs
Expand Up @@ -286,7 +286,12 @@ impl<'a> EntryFields<'a> {
}

fn path(&self) -> io::Result<Cow<Path>> {
bytes2path(self.path_bytes())
let mut path = self.path_lossy();
if cfg!(windows) && path.starts_with("//") {
// Avoid being parsed as UNC
path.insert_str(0, "./");
}
Ok(Cow::Owned(PathBuf::from(path)))
}

fn path_bytes(&self) -> Cow<[u8]> {
Expand Down Expand Up @@ -379,12 +384,13 @@ impl<'a> EntryFields<'a> {

let mut file_dst = dst.to_path_buf();
{
let path = self.path().map_err(|e| {
TarError::new(
format!("invalid path in entry header: {}", self.path_lossy()),
e,
)
})?;
let path = self.path()
.map_err(|e| {
TarError::new(
format!("invalid path in entry header: {}", self.path_lossy()),
e,
)
})?;
for part in path.components() {
match part {
// Leading '/' characters, root paths, and '.'
Expand Down

0 comments on commit c0ffc46

Please sign in to comment.