mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 10:43:30 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { plistNestingLimitMessage } from "./apple/plistValue.js";
|
|
import { parseXmlPropertyList } from "./propertyListKeys.js";
|
|
|
|
it("preserves array values and comment-like string content after leading trivia", () => {
|
|
const parsed = parseXmlPropertyList(
|
|
'\uFEFF /* header */ // array\r\n ("https://example.test", "/*literal*/")',
|
|
);
|
|
expect(parsed.value).toEqual(["https://example.test", "/*literal*/"]);
|
|
expect(parsed.numberLiterals.incomplete).toBe(true);
|
|
});
|
|
|
|
it("retains prototype-key omission through commented OpenStep dispatch", () => {
|
|
const parsed = parseXmlPropertyList(
|
|
'/* header */ { __proto__ = { secret = value; }; kept = "/*literal*/"; }',
|
|
);
|
|
expect(parsed.value).toEqual({ kept: "/*literal*/" });
|
|
expect(parsed.omittedPrototypeKeys).toBe(1);
|
|
});
|
|
|
|
it("retains the depth preflight after a leading comment", () => {
|
|
expect(() =>
|
|
parseXmlPropertyList(`// header\n${"(".repeat(129)}x${")".repeat(129)}`),
|
|
).toThrow(plistNestingLimitMessage());
|
|
});
|
|
|
|
it.each(["// header only", "/* unterminated", "/* header */ not-a-container"])(
|
|
"does not admit missing or unsupported root values: %s",
|
|
(source) => {
|
|
expect(() => parseXmlPropertyList(source)).toThrow();
|
|
},
|
|
);
|
|
|
|
it("keeps XML comments on the XML decoding path", () => {
|
|
expect(
|
|
parseXmlPropertyList(
|
|
"<!-- header --> <plist><string>value</string></plist>",
|
|
).value,
|
|
).toBe("value");
|
|
});
|