fix(apple): decode bundle plist bytes before executable lookup
This commit is contained in:
@@ -8,6 +8,7 @@ import { z } from "zod";
|
||||
import { BinaryTargetError } from "../domain/configurationErrors.js";
|
||||
import { isPathWithinRoot } from "../domain/localPath.js";
|
||||
import { parseXmlPropertyList } from "../domain/propertyListKeys.js";
|
||||
import { decodeXmlPlistText } from "../domain/propertyListXmlText.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
@@ -194,7 +195,7 @@ const resolveLayoutExecutable = async (
|
||||
? await (fileSystem.decodeBinaryPlist ?? readBinaryPlistExecutable)(
|
||||
plistPath,
|
||||
)
|
||||
: parseXmlPlistExecutable(plist.toString("utf8"));
|
||||
: parseXmlPlistExecutable(decodeXmlPlistText(plist));
|
||||
} catch (cause: unknown) {
|
||||
return err(
|
||||
new BinaryTargetError(
|
||||
@@ -203,7 +204,7 @@ const resolveLayoutExecutable = async (
|
||||
? `permission denied decoding app Info.plist ${plistPath}${codeDescription(cause)}`
|
||||
: isSystemErrorCode(cause)
|
||||
? `could not decode app Info.plist ${plistPath}${codeDescription(cause)}`
|
||||
: `app Info.plist is malformed or lacks CFBundleExecutable: ${plistPath}`,
|
||||
: `app Info.plist is malformed, unsupported, or lacks CFBundleExecutable: ${plistPath}${cause instanceof Error ? ` (${cause.message})` : ""}`,
|
||||
{ cause },
|
||||
),
|
||||
);
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from "./NibViewHierarchy.js";
|
||||
import { jsonValueSchema, type JsonValue } from "../../domain/jsonValue.js";
|
||||
|
||||
import { decodeXmlPlistText } from "./XmlPropertyListText.js";
|
||||
import { decodeXmlPlistText } from "../../domain/propertyListXmlText.js";
|
||||
|
||||
const MAX_AGGREGATE_INPUT_BYTES = 32 * 1024 * 1024;
|
||||
const MAX_AGGREGATE_DECODE_BYTES = 256 * 1024 * 1024;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { decodeXmlPlistText } from "./XmlPropertyListText.js";
|
||||
import { decodeXmlPlistText } from "../../domain/propertyListXmlText.js";
|
||||
|
||||
/** Reason reported when an archive would exceed the shared decoding budget. */
|
||||
export type InterfaceBuilderBudgetReason = "aggregate_decode_budget_exhausted";
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
import { DirectoryArtifactReader } from "../DirectoryArtifactReader.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
|
||||
import { decodeXmlPlistText } from "./XmlPropertyListText.js";
|
||||
import { decodeXmlPlistText } from "../../domain/propertyListXmlText.js";
|
||||
|
||||
const MAX_BYTES = 64 * 1024 * 1024;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { TextDecoder } from "node:util";
|
||||
|
||||
/** Decode BOM-aware XML plist text with fatal byte validation. */
|
||||
export const decodeXmlPlistText = (bytes: Buffer): string => {
|
||||
export const decodeXmlPlistText = (bytes: Uint8Array): string => {
|
||||
const encoding =
|
||||
bytes[0] === 0xff && bytes[1] === 0xfe
|
||||
? "utf-16le"
|
||||
Reference in New Issue
Block a user