Repository navigation
Description
Follow-up from #417 (zip 2.4.2 -> 9.0.4). No test covers ZIP entry names with non-ASCII characters. This issue lists how such a name is decoded and checked today, so the team can decide the rule and add tests.
How a name reaches the Library today
-
Decoding (zip 9.0.4).
ZipFile::name()(zip-9.0.4/src/read/zipfile.rs:83) callsZipFileData::name(zip-9.0.4/src/types.rs:122-131). It uses the raw bytes as UTF-8 when they are valid UTF-8, whatever the language-encoding flag (bit 11) says, and CP437 otherwise. zip 2.4.2 used the flag (zip-2.4.2/src/read.rs:1306-1315): flag set means lossy UTF-8, flag clear means CP437. So a CP437 name from an old Windows tool whose bytes happen to be valid UTF-8 now shows different characters than in 2.4.2. -
Info-ZIP Unicode Path extra field (0x7075). When its CRC matches the header name, zip 9 replaces the header name with the extra field's UTF-8 name (
zip-9.0.4/src/extra_fields/extra_field.rs:278-288). The name the runtime checks and writes can then differ from the name another ZIP tool shows for the same entry. -
Checks in the runtime (line numbers at deps: move zip to 9.x for RUSTSEC-2026-0367/0368/0369 #417 head
5873d2f7). Every ZIP reader takes the decoded&str:- whole-archive extract:
extract_zip_archive(elastos/crates/elastos-server/src/library.rs:5429) ->zip_entry_enclosed_path(library.rs:5485) ->archive_entry_uri(library.rs:5503) ->clean_object_name(library.rs:6730); - list, preview and selected extract:
list_zip_archive_entries(library.rs:4454),preview_zip_archive_entry(library.rs:4232),collect_selected_zip_writes(library.rs:4937) ->normalized_archive_entry_path(library.rs:4509).
These compare bytes only. They look for the ASCII separators
/and\, NUL,.and... There is no Unicode normalization and no check of look-alike characters. - whole-archive extract:
Open questions (team decision; nothing here is a known escape on Linux)
- Normalization.
café.txtin NFC and in NFD are two different names to the runtime, so one archive can hold both and write two files that look the same. On a default macOS volume (APFS, case- and normalization-insensitive) both names can open the same file, so the second entry may write over the first. The same is true forA.txtanda.txt. Not tested. Should extract normalize to NFC, or refuse an archive with two names that are equal after NFC? - Look-alike separators.
U+2215(division slash),U+FF0F(fullwidth solidus) andU+FF3C(fullwidth reverse solidus) pass as ordinary characters. That is safe for the path on Linux and macOS, but the Library shows a name that looks like a folder path. Should these be refused or shown escaped? - Control and bidi characters.
U+202E(right-to-left override) and other control characters pass, so a name like<U+202E>txt.exeis shown asexe.txt.archive_entry_display_name(library.rs:4547) shows the raw name. - Selected entries.
outcome.is_selected(library.rs:4696) matches the user's selection against the decoded name byte for byte. A name the browser sends back in another normalization form does not match.
What done looks like
- A decided rule for the four points above, in one place in
library.rs. - Tests with hostile archives: an NFC/NFD pair, a CP437 name without the flag, a valid-UTF-8 name without the flag, a Unicode Path extra field that differs from the header name, look-alike separators, and a bidi override. Each test states the expected refusal or the exact name written.
Activity
SashaMIT commentedon Oct 17, 2026
Related: in zip 9,
ZipFile::name()is fallible, and the four readers (library.rs:4243,:4464,:4949,:5442at #417 head5873d2f7) fail the whole list, preview or extract with "invalid ZIP archive entry: …" if it fails. In zip 9.0.4 no byte string reaches that error (zip-9.0.4/src/cp437.rs:17-31), so it is untested. If a rule from this issue makes a name undecodable or refused, decide whether that one entry is shown as blocked or the whole archive is refused. See the #417 body, "Other API changes".Generated by Claude Code