From 5da1d3540a121576520b652bf0c2d8d8be44d4e9 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 6 Dec 2026 10:30:09 +0800 Subject: [PATCH] refactor(zip): share the entry name UTF-8 decoder (#17358) --- src/resources/ZipArtifactReader.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/resources/ZipArtifactReader.ts b/src/resources/ZipArtifactReader.ts index d93e8a3ad2..47dc4689cb 100644 --- a/src/resources/ZipArtifactReader.ts +++ b/src/resources/ZipArtifactReader.ts @@ -66,7 +66,7 @@ import type { ZipPackageFormat } from "../domain/zipPackageFormat.js"; import { artifactExpansionBudgetBytes } from "../domain/artifactExpansionBudget.js"; import type { StableRegularFileDescriptor } from "../filesystem/RegularFile.js"; import { readFileHandleRange } from "../filesystem/readFileHandleRange.js"; -import { strictUtf8Decoder } from "../domain/strictUtf8.js"; +import { decodeStrictUtf8 } from "../domain/strictUtf8.js"; import { decodeZipCp437 } from "../domain/zip/zipEntryText.js"; import { invariantViolation } from "../domain/internalInvariant.js"; import { @@ -74,8 +74,6 @@ import { zstandardFrameChunks, } from "../domain/compression/zstandardFrameChunks.js"; -const ZIP_UTF8_DECODER = strictUtf8Decoder("preserve"); - /** Fixed method-93 decoder window: 2^27 bytes, matching the ELF/GPU decoders. */ const ZIP_ZSTANDARD_WINDOW_LOG_MAX = 27; @@ -598,7 +596,7 @@ const decodeStrictZipUtf8 = (bytes: Uint8Array, message: string): string => { try { // Keep the adapter's path semantics aligned with zip.js's default decoder: // a leading U+FEFF is part of a member name, not a transport signature. - return ZIP_UTF8_DECODER.decode(bytes); + return decodeStrictUtf8(bytes, "preserve"); } catch (cause: unknown) { throw malformedArtifact("zip", message, { cause, field: "name" }); }