Skip to content

Commit 9c39e6d

Browse files
authored
fix(ios): decode zip entry names as UTF-8 when extracting the bundle (#392)
1 parent 25047ad commit 9c39e6d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

resources/xcode/NativePHP/AppUpdateManager.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ class AppUpdateManager {
118118
var fileDataMap: [(path: URL, data: Data)] = []
119119

120120
for entry in archive {
121-
let destinationPath = destinationURL.appendingPathComponent(entry.path)
121+
// ZIPFoundation 0.9.19's `entry.path` decodes as CP437 unless the EFS bit
122+
// is set on the entry — and macOS `zip` often omits that flag even for
123+
// UTF-8 names, producing mojibake (⚡️ → ΓÜí∩╕Å). Force UTF-8 decode via
124+
// path(using:); fall back to `entry.path` only if the bytes aren't valid
125+
// UTF-8 (which shouldn't happen for archives we build).
126+
let utf8Path = entry.path(using: .utf8)
127+
let rawPath = utf8Path.isEmpty ? entry.path : utf8Path
128+
129+
// Normalize to NFC: macOS sources may emit NFD filenames; iOS APFS stores
130+
// bytes verbatim, but PHP autoloaders look up the NFC form.
131+
let normalizedPath = (rawPath as NSString).precomposedStringWithCanonicalMapping
132+
let destinationPath = destinationURL.appendingPathComponent(normalizedPath)
122133

123134
switch entry.type {
124135
case .directory:

0 commit comments

Comments
 (0)