From 6a965d117eb95204ab39f0f3b35b02a7cd0c6021 Mon Sep 17 00:00:00 2001 From: berce <75228263+bercedev@users.noreply.github.com> Date: Mon, 19 Oct 2026 01:22:44 +0300 Subject: [PATCH] fix(artifacts): keep a member's own name when its logical path is NFC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inventory stores each member under its NFC spelling for lookup, so a ZIP member named "café.txt" (decomposed) showed up only as "café.txt", with nothing in the Evidence that recovers the name the archive holds. Record that spelling as an occurrence limitation when NFC changes it, next to the existing note for a stripped "./" prefix. The check sits where occurrences are built, so it covers every reader. Fixes #5108 --- .../inventory/ArtifactGraphConstruction.ts | 11 +++++++++- .../artifactZipRelativePaths.test.ts | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/artifacts/inventory/ArtifactGraphConstruction.ts b/src/artifacts/inventory/ArtifactGraphConstruction.ts index 4d80479151d..eb87bde350c 100644 --- a/src/artifacts/inventory/ArtifactGraphConstruction.ts +++ b/src/artifacts/inventory/ArtifactGraphConstruction.ts @@ -8,6 +8,7 @@ import { import { artifactEdgeId, artifactIdForContent, + logicalPathNfc, occurrenceIdForLocation, } from "../../domain/artifactIdentity.js"; import type { ArtifactEntry } from "../ArtifactReader.js"; @@ -108,7 +109,15 @@ export const createOccurrence = ( entry.byteOffset === null || entry.declaredSize === null ? null : { offset: entry.byteOffset, length: entry.declaredSize }, - limitations: [...entry.limitations], + limitations: [ + ...entry.limitations, + // The logical path is NFC for lookup; keep the member's own spelling. + ...(logicalPathNfc(entry.path) === entry.path + ? [] + : [ + `Member name ${JSON.stringify(entry.path)} is not in Unicode NFC; its logical path uses the NFC spelling.`, + ]), + ], }; }; diff --git a/tests/boundary/filesystem/artifactZipRelativePaths.test.ts b/tests/boundary/filesystem/artifactZipRelativePaths.test.ts index 6a346ddb902..3bea960e686 100644 --- a/tests/boundary/filesystem/artifactZipRelativePaths.test.ts +++ b/tests/boundary/filesystem/artifactZipRelativePaths.test.ts @@ -33,6 +33,26 @@ it("retains distinct occurrences when ZIP paths normalize to the same child", as ); }); +it("keeps a decomposed ZIP member name beside its NFC logical path", async () => { + // #5108: lookup uses NFC, but the source spelling must stay recoverable. + const root = await createTestTempDirectory("rea-zip-nfc-name-"); + const path = join(root, "decomposed.zip"); + await writeOrderedZip(path, ["café.txt", "plain.txt"]); + + const inventory = await inventoryArtifact(path); + expect(inventory.occurrences).toContainEqual( + expect.objectContaining({ + logical_path: "café.txt", + limitations: [ + 'Member name "café.txt" is not in Unicode NFC; its logical path uses the NFC spelling.', + ], + }), + ); + expect(inventory.occurrences).toContainEqual( + expect.objectContaining({ logical_path: "plain.txt", limitations: [] }), + ); +}); + it.each([".", "././."])( "rejects a non-directory ZIP entry spelled %s instead of skipping it as a root marker", async (name) => {