Files
reverse-engineering-anything/src/domain/propertyListKeys.ts
T
f235c00ef7 fix(app-bundle): apply the Info.plist decode budget to XML plists (#6699)
* fix(app-bundle): apply the plist decode budget to the XML branch

* test(app-bundle): cover the XML plist decode budget

* decode xml plist once, pass the text to the decode preflight

* fix(app-bundle): keep OpenStep plists out of the XML preflight, keep budget failures typed

OpenStep Info.plist text is not XML, so quoted markup inside it is string
data. Run the XML entity-expansion preflight only on actual XML input,
using the same format check the parser already uses. A valid OpenStep
bundle with a DOCTYPE-looking quoted string no longer fails the budget.

Budget exhaustion also keeps its own error: the resolver now returns a
typed bundle_info_plist_decode_budget_exceeded failure naming the 16 MiB
allowance instead of the malformed-plist diagnosis.

* Fix test names and budget error classification after the merge

* fix: regenerate user-visible error catalogue for plist budget constraint

* test: pin budget-exceeded bundle target to its catalogue row

* refactor(plist): give Info.plist decoding a shared owner

---------

Co-authored-by: Dextheking1 <Dextheking1@users.noreply.github.com>
Co-authored-by: benjaminkincses <4175097+benjaminkincses@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 11:24:09 +00:00

46 lines
1.7 KiB
TypeScript

import { decodeXmlPropertyList } from "./propertyListXml.js";
import { preflightXmlPropertyListDecode } from "./apple/propertyListDecodeBudget.js";
import {
decodeOpenStepPropertyList,
startsOpenStepPropertyList,
} from "./propertyListOpenStep.js";
import {
createPlistNumberCollector,
type PlistNumberLiterals,
} from "./apple/plistNumbers.js";
import { MAX_PLIST_DEPTH } from "./apple/plistValue.js";
import {
createPlistDuplicateKeyCollector,
type PlistDuplicateKeys,
} from "./apple/plistDuplicateKeys.js";
/** Values and numeric source facts decoded together; OpenStep numbers remain unknown. */
export interface ParsedPropertyList {
readonly value: unknown;
readonly numberLiterals: PlistNumberLiterals;
/** Keys a dictionary declared more than once; `value` keeps the last. */
readonly duplicateKeys: PlistDuplicateKeys;
}
/** Decode XML or the existing OpenStep container form, retaining every dictionary key.
* The optional XML byte budget applies after format selection. In OpenStep,
* quoted markup is string data and does not introduce XML expansion.
*/
export const parseXmlPropertyList = (
text: string,
maximumDepth = MAX_PLIST_DEPTH,
maximumXmlDecodeBytes?: number,
): ParsedPropertyList => {
if (!startsOpenStepPropertyList(text)) {
if (maximumXmlDecodeBytes !== undefined)
preflightXmlPropertyListDecode(text, maximumXmlDecodeBytes);
return decodeXmlPropertyList(text, maximumDepth);
}
const duplicates = createPlistDuplicateKeyCollector();
return {
value: decodeOpenStepPropertyList(text, maximumDepth, duplicates),
numberLiterals: createPlistNumberCollector().result(true),
duplicateKeys: duplicates.result(),
};
};