mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
refactor(zip): share the entry name UTF-8 decoder (#17358)
This commit is contained in:
@@ -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" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user