diff --git a/src/domain/propertyListKeys.test.ts b/src/domain/propertyListKeys.test.ts index e98f8430c1..ff3ca7bf32 100644 --- a/src/domain/propertyListKeys.test.ts +++ b/src/domain/propertyListKeys.test.ts @@ -1,7 +1,20 @@ import { describe, expect, it } from "vitest"; import { parse } from "plist"; -import { omitPrototypeKeys, parseXmlPropertyList } from "./propertyListKeys.js"; +import { + decodeXmlText, + omitPrototypeKeys, + parseXmlPropertyList, +} from "./propertyListKeys.js"; + +it("preserves unknown named entities that collide with object prototype properties", () => { + expect( + decodeXmlText("&constructor; &toString; &valueOf; &hasOwnProperty;"), + ).toBe("&constructor; &toString; &valueOf; &hasOwnProperty;"); + expect(decodeXmlText("&<>"'AB")).toBe( + "&<>\"'AB", + ); +}); const plist = (body: string) => `${body}`; diff --git a/src/domain/propertyListKeys.ts b/src/domain/propertyListKeys.ts index de929146bc..7ed9157f83 100644 --- a/src/domain/propertyListKeys.ts +++ b/src/domain/propertyListKeys.ts @@ -75,7 +75,9 @@ export const decodeXmlText = (text: string): string => : undefined; if (codePoint !== undefined) return codePoint <= 0x10ffff ? String.fromCodePoint(codePoint) : entity; - return (name === undefined ? undefined : XML_ENTITIES[name]) ?? entity; + return name !== undefined && Object.hasOwn(XML_ENTITIES, name) + ? XML_ENTITIES[name]! + : entity; }, );