diff --git a/src/domain/propertyListKeys.test.ts b/src/domain/propertyListKeys.test.ts
index c63eac59d5..d0953efedd 100644
--- a/src/domain/propertyListKeys.test.ts
+++ b/src/domain/propertyListKeys.test.ts
@@ -412,7 +412,7 @@ describe("OpenStep plist owned depth", () => {
});
});
-it.each(["\u0085", "\u2028", "\u2029"])(
+it.each(["\r", "\r\n", "\u0085", "\u2028", "\u2029"])(
"preserves key identity around inter-element separator %j",
(separator) => {
const parsed = parseXmlPropertyList(
diff --git a/src/domain/propertyListXml.test.ts b/src/domain/propertyListXml.test.ts
index 12318e92c1..719a7d4546 100644
--- a/src/domain/propertyListXml.test.ts
+++ b/src/domain/propertyListXml.test.ts
@@ -301,6 +301,20 @@ it("binds raw literals to their nodes across normalized line endings and UTF-16
]);
});
+it("keeps literal carriage returns in keys and strings, as CoreFoundation does", () => {
+ // plutil reads these four keys as distinct and each value as written.
+ const parsed = parseXmlPropertyList(
+ "\r\ra\r\nbx\ry\r\nz\ra\nb\ra\rb\r42\rdata\r\rAAEC\r\n\r\r\r",
+ );
+ expect(parsed.value).toEqual({
+ "a\r\nb": "x\ry\r\nz",
+ "a\nb": "c\rd",
+ "a\rb": 42,
+ data: new Uint8Array([0, 1, 2]),
+ });
+ expect(parsed.duplicateKeys).toMatchObject({ dictionaries: 0 });
+});
+
it("preserves Unicode line separators in plist string values", () => {
const value = "a\u0085b\u2028c\u2029d";
expect(
diff --git a/src/domain/propertyListXmlSource.ts b/src/domain/propertyListXmlSource.ts
index 6cf0e1ab5f..40e1588630 100644
--- a/src/domain/propertyListXmlSource.ts
+++ b/src/domain/propertyListXmlSource.ts
@@ -27,8 +27,9 @@ export const readXmlPlistSource = (
text: string,
maximumDepth = MAX_PLIST_DEPTH,
) => {
- const normalized = text.replace(XML_LINE_ENDING, "\n");
- const parsed = parseXmlDocument(normalized, {
+ // CoreFoundation keeps a literal CR in a key or string, so the document is
+ // read as written; XML 1.0 line-ending normalization would rewrite both.
+ const parsed = parseXmlDocument(text, {
doctype: "allow",
lineEndings: "preserve",
});
diff --git a/tests/boundary/cli/nativePlistCli.test.ts b/tests/boundary/cli/nativePlistCli.test.ts
index 43dc3a6bb7..dcd450a58a 100644
--- a/tests/boundary/cli/nativePlistCli.test.ts
+++ b/tests/boundary/cli/nativePlistCli.test.ts
@@ -229,6 +229,8 @@ describe.skipIf(process.platform !== "darwin")(
"CFBundleIdentifiercom.example.types",
"BlobAAEC",
"Separatorsa\u0085b\u2028c\u2029d",
+ // CoreFoundation keeps a literal CR, so plutil's binary conversion holds it too.
+ "Returnsa\rb\r\nc\nd",
"Built2020-01-01T00:00:00Z",
// Parse the unsigned extended year as a UTC field, without JS string-date inference.
"Far11507-08-17T05:20:00Z",
@@ -263,6 +265,7 @@ describe.skipIf(process.platform !== "darwin")(
CFBundleIdentifier: "com.example.types",
Blob: { $plist_type: "data", base64: "AAEC" },
Separators: "a\u0085b\u2028c\u2029d",
+ Returns: "a\rb\r\nc\nd",
Built: {
$plist_type: "date",
iso8601: "2020-01-01T00:00:00.000Z",