Skip to content

Filename decoding issue for zip files archived by macOS #63

Closed
@benoitsan

Description

@benoitsan

Summary

Zip entries filenames are not decoded correctly when reading the content of a zip file produced by macOS.

Steps to Reproduce

  1. on macOS 10.13.4, make a zip file archive.zip with 2 files "Benoît.txt" and "pic👨‍👩‍👧‍👦🎂.jpg"
  2. 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 the Entry struct in Entry.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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions