Skip to content

Commit

Permalink
Try again removing colons
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 10, 2024
1 parent dee3cec commit 7aa2848
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public class Zip {
fileName[Int(fileInfo.size_filename)] = 0

var pathString = String(cString: fileName)

#if os(Windows)
pathString = pathString.replacingOccurrences(of: ":", with: "_")
#endif

guard !pathString.isEmpty else {
throw ZipError.unzipFail
}
Expand All @@ -110,7 +115,7 @@ public class Zip {
}

let fullPath = destination.appendingPathComponent(pathString).standardizedFileURL.path
// `.standardized` removes any `..` to move a level up.
// `.standardizedFileURL` removes any `..` to move a level up.
// If we then check that the `fullPath` starts with the destination directory we know we are not extracting "outside" the destination.
guard fullPath.starts(with: destination.standardizedFileURL.path) else {
throw ZipError.unzipFail
Expand Down Expand Up @@ -162,8 +167,6 @@ public class Zip {
throw ZipError.unzipFail
}

// TODO: Set permissions properly on Windows
#if !os(Windows)
// Set file permissions from current `fileInfo`
if fileInfo.external_fa != 0 {
let permissions = (fileInfo.external_fa >> 16) & 0x1FF
Expand All @@ -176,7 +179,6 @@ public class Zip {
}
}
}
#endif

ret = unzGoToNextFile(zip)

Expand Down

0 comments on commit 7aa2848

Please sign in to comment.