zipEntry.name


条目的名称是从中央目录解码的,它被视为权威 — 当本地文件头不一致时会被忽略,所以一个头信息不匹配(“ZIP混乱”)的压缩文件不会让 name 与读取到的内容不一致。当存在有效的 Info-ZIP Unicode 路径附加字段 (0x7075) 时,会从中解码字节;否则,如果语言编码标志(通用位 11)被设置 或字节是有效的 UTF-8(很多工具写 UTF-8 名称时从未设置过该标志),就按 UTF-8 解码;如果都不是,则按 CP437 — 历史默认 — 解码。原始字节请参见 zipEntry.nameBuffer。

🌐 The entry's name, decoded from the central directory, which is treated as authoritative — a local file header that disagrees is ignored, so a mismatched-header ("ZIP-confusion") archive cannot make name disagree with what is read. The bytes are decoded from a valid Info-ZIP Unicode Path extra field (0x7075) when one is present; otherwise as UTF-8 when the language-encoding flag (general-purpose bit 11) is set or the bytes are valid UTF-8 (plenty of tools wrote UTF-8 names without ever setting the flag); and as CP437 — the historical default — only when they are not. See zipEntry.nameBuffer for the raw bytes.

名称会被逐字返回:它从不进行规范化,包含 ..、开头的 /、驱动器字母或反斜杠的名称既不会被重写,也不会被拒绝。ZipFile/ZipBuffer 从不写入磁盘,因此在解压时防范路径遍历(“Zip Slip”)是调用方的责任。

🌐 The name is returned verbatim: it is never normalized, and a name containing .., a leading /, a drive letter, or backslashes is neither rewritten nor rejected. A ZipFile/ZipBuffer never writes to disk, so guarding against path traversal ("Zip Slip") when extracting is the caller's responsibility.