[PR #3241] [CLOSED] fix(artifacts): decode unflagged ZIP names as the legacy character set #5667

Closed
opened 2026-10-31 01:08:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3241
Author: @gongfpp
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/3237-legacy-zip-filename-encoding


📝 Commits (1)

  • be73ad0 fix(artifacts): decode unflagged ZIP names as the legacy character set

📊 Changes

2 files changed (+32 additions, -0 deletions)

View changed files

📝 src/artifacts/ZipArtifactReader.test.ts (+26 -0)
📝 src/artifacts/ZipArtifactReader.ts (+6 -0)

📄 Description

Summary

inspect-artifact silently reinterprets a valid legacy ZIP filename as UTF-8 when its bytes also form a valid UTF-8 sequence, and then rejects two distinct members as a path collision. ZipArtifactReader supplies its own CP437 decoder but leaves zip.js's filenameEncoding unset, so zip.js decides the unflagged name first.

Refs #3237. The reader now names the legacy character set, as ZIP APPNOTE D.1-D.2 requires when general-purpose bit 11 is unset.

Problem and expected behavior

zip-reader.js computes filenameUTF8 = languageEncodingFlag || (!filenameEncoding && isUTF8Text(rawFilename)). With no filenameEncoding, an unflagged name whose bytes are also valid UTF-8 is decoded as UTF-8 before REA's decoder runs.

For the reported archive, both members hold the raw name bytes c3 a9 2e 74 78 74, member 0 leaves bit 11 unset and member 1 sets it, and there is no Unicode Path extra field. Python's zipfile reads member 0 as CP437 (\u251c\u2310.txt) and member 1 as UTF-8 (\u00e9.txt). Expected: REA reports both spellings; bit-11 UTF-8 and a valid Unicode Path extra field stay authoritative; path, collision, CRC, overlap and size validation stay intact.

Change and scope

  • src/artifacts/ZipArtifactReader.ts: the reader options name filenameEncoding: "cp437", so the legacy path reaches the existing decoders instead of a UTF-8 guess.
  • src/artifacts/ZipArtifactReader.test.ts: a focused regression reads the reported archive and asserts both names.

Intentionally not included: no change to path validation, the decompression budget, CRC or overlap checks, and no new encoding option for callers.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the ZIP member-name owner in ZipArtifactReader; zip.js still parses the archive and REA still validates paths.
  • Contribution scope fit: ordinary fix inside the existing ZIP support and the declared behavior of #2365.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none; CP437 is the legacy ZIP default rather than a provider choice.
  • Evidence, artifact, provenance, or reconstruction contract: member names and their raw bytes keep the same relationship; a legacy name is no longer rewritten.

Expected effects (check known effects; use documentation-only on its own).

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: ZipArtifactReader.test.ts gains one case carrying the issue's archive as a base64 fixture; it fails with the previous options and passes with the fix.
  • Base reproduction: the reported archive and inspect-artifact command; the pre-change reader returns ["\u00e9.txt", "\u00e9.txt"].
  • User-visible CLI/MCP output: a legacy member keeps its CP437 name instead of colliding with the UTF-8 member.
  • Remaining proof gaps: no producer was re-run to generate another legacy archive; the fixture is the one from the report.

Validation performed

  • npx vitest run --project adapters src/artifacts/ZipArtifactReader.test.ts — 7 passed
  • npx vitest run --project adapters --project boundary src/artifacts tests/boundary/artifacts — 137 passed
  • npx tsc --noEmit — clean
  • npx oxfmt --check <changed files> — correct format
  • npx oxlint <changed files> — 0 errors

Compatibility, safety, and release

  • Breaking changes or migration steps: none. An archive that previously failed a collision check now inventories both members; ASCII and bit-11 UTF-8 names are unaffected.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; local archive reading only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; no new input, side effect or process boundary.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3241 **Author:** [@gongfpp](https://github.com/gongfpp) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/3237-legacy-zip-filename-encoding` --- ### 📝 Commits (1) - [`be73ad0`](https://github.com/morluto/rea/commit/be73ad0ca08ee1f61a8d1cd40425810baad1b9a0) fix(artifacts): decode unflagged ZIP names as the legacy character set ### 📊 Changes **2 files changed** (+32 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/ZipArtifactReader.test.ts` (+26 -0) 📝 `src/artifacts/ZipArtifactReader.ts` (+6 -0) </details> ### 📄 Description ## Summary `inspect-artifact` silently reinterprets a valid legacy ZIP filename as UTF-8 when its bytes also form a valid UTF-8 sequence, and then rejects two distinct members as a path collision. `ZipArtifactReader` supplies its own CP437 decoder but leaves zip.js's `filenameEncoding` unset, so zip.js decides the unflagged name first. Refs #3237. The reader now names the legacy character set, as ZIP APPNOTE D.1-D.2 requires when general-purpose bit 11 is unset. ## Problem and expected behavior `zip-reader.js` computes `filenameUTF8 = languageEncodingFlag || (!filenameEncoding && isUTF8Text(rawFilename))`. With no `filenameEncoding`, an unflagged name whose bytes are also valid UTF-8 is decoded as UTF-8 before REA's decoder runs. For the reported archive, both members hold the raw name bytes `c3 a9 2e 74 78 74`, member 0 leaves bit 11 unset and member 1 sets it, and there is no Unicode Path extra field. Python's `zipfile` reads member 0 as CP437 (`\u251c\u2310.txt`) and member 1 as UTF-8 (`\u00e9.txt`). Expected: REA reports both spellings; bit-11 UTF-8 and a valid Unicode Path extra field stay authoritative; path, collision, CRC, overlap and size validation stay intact. ## Change and scope - `src/artifacts/ZipArtifactReader.ts`: the reader options name `filenameEncoding: "cp437"`, so the legacy path reaches the existing decoders instead of a UTF-8 guess. - `src/artifacts/ZipArtifactReader.test.ts`: a focused regression reads the reported archive and asserts both names. Intentionally not included: no change to path validation, the decompression budget, CRC or overlap checks, and no new encoding option for callers. ## Contract and boundary impact - Semantic owner and earliest changed stage: the ZIP member-name owner in `ZipArtifactReader`; zip.js still parses the archive and REA still validates paths. - Contribution scope fit: ordinary fix inside the existing ZIP support and the declared behavior of #2365. - CLI and MCP/tool-catalog contract: none. - Provider, bridge, target-format, or platform compatibility: none; CP437 is the legacy ZIP default rather than a provider choice. - Evidence, artifact, provenance, or reconstruction contract: member names and their raw bytes keep the same relationship; a legacy name is no longer rewritten. Expected effects (check known effects; use documentation-only on its own). - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `ZipArtifactReader.test.ts` gains one case carrying the issue's archive as a base64 fixture; it fails with the previous options and passes with the fix. - Base reproduction: the reported archive and `inspect-artifact` command; the pre-change reader returns `["\u00e9.txt", "\u00e9.txt"]`. - User-visible CLI/MCP output: a legacy member keeps its CP437 name instead of colliding with the UTF-8 member. - Remaining proof gaps: no producer was re-run to generate another legacy archive; the fixture is the one from the report. ## Validation performed - `npx vitest run --project adapters src/artifacts/ZipArtifactReader.test.ts` — 7 passed - `npx vitest run --project adapters --project boundary src/artifacts tests/boundary/artifacts` — 137 passed - `npx tsc --noEmit` — clean - `npx oxfmt --check <changed files>` — correct format - `npx oxlint <changed files>` — 0 errors ## Compatibility, safety, and release - Breaking changes or migration steps: none. An archive that previously failed a collision check now inventories both members; ASCII and bit-11 UTF-8 names are unaffected. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; local archive reading only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; no new input, side effect or process boundary. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:08:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5667
No description provided.