Closed
Description
Summary
Zip entries filenames are not decoded correctly when reading the content of a zip file produced by macOS.
Steps to Reproduce
- on macOS 10.13.4, make a zip file
archive.zip
with 2 files "Benoît.txt" and "pic👨👩👧👦🎂.jpg" - Read the path entries of this zip archive on iOS 11.3.1:
let archive = Archive(url: /urlto:archive.zip/, accessMode: .read)!
for entry in archive {
print("entry: \(entry.path)")
}
Expected Results
It should log "Benoît.txt" and "pic👨👩👧👦🎂.jpg"
Actual Results
It logs "Benoît.txt" and "pic👨‍👩‍👧‍👦🎂.jpg"
Regression & Version
-
I'm using ZIPFoundation on the master branch (e44ff6b)
-
The workaround to fix this issue is to force to use the UTF-8 encoder in the
path
getter of theEntry
struct inEntry.Swift
public var path: String {
...
let encoding = String.Encoding.utf8 //isUTF8 ? String.Encoding.utf8 : codepage437
return String(data: self.centralDirectoryStructure.fileNameData, encoding: encoding) ?? ""
}
Related Link
archive.zip
to reproduce this issue. https://www.dropbox.com/s/5tuf7ll4hapwgp1/utfissue.zip?dl=0