fix(target): decode app Info.plist executables with an XML parser
The pattern-based reader decoded entities twice, ignored numeric character references and CDATA, and could match a commented or nested CFBundleExecutable key, so valid app bundles reported a missing program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4a6c17ce83
commit
c182f72ad3
@@ -187,6 +187,62 @@ describe("app executable filename fidelity", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
["an escaped entity reference", "a&lt;b", "a<b"],
|
||||
["a numeric character reference", "a b", "a b"],
|
||||
["a CDATA section", "<![CDATA[a&b]]>", "a&b"],
|
||||
])(
|
||||
"decodes an XML plist executable name containing %s",
|
||||
async (_case, encoded, name) => {
|
||||
const directory = await createTestTempDirectory("rea-app-xml-name-");
|
||||
const app = join(directory, "Encoded.app");
|
||||
const contents = join(app, "Contents");
|
||||
const executable = join(contents, "MacOS", name);
|
||||
await mkdir(join(contents, "MacOS"), { recursive: true });
|
||||
await writeFile(
|
||||
join(contents, "Info.plist"),
|
||||
`<plist><dict><key>CFBundleExecutable</key><string>${encoded}</string></dict></plist>`,
|
||||
);
|
||||
await writeFile(executable, thinMach(0xfeedfacf, 0x0100000c));
|
||||
const result = await parseBinaryTarget(app, directory, "arm64");
|
||||
expect(result.ok && result.value).toMatchObject({
|
||||
path: await realpath(executable),
|
||||
format: "mach-o",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("reads the top-level executable key rather than commented or nested text", async () => {
|
||||
const directory = await createTestTempDirectory("rea-app-xml-key-");
|
||||
const app = join(directory, "Nested.app");
|
||||
const contents = join(app, "Contents");
|
||||
const executable = join(contents, "MacOS", "App");
|
||||
await mkdir(join(contents, "MacOS"), { recursive: true });
|
||||
await writeFile(
|
||||
join(contents, "Info.plist"),
|
||||
[
|
||||
"<plist><dict>",
|
||||
"<!-- <key>CFBundleExecutable</key><string>Old</string> -->",
|
||||
"<key>NSExtension</key><dict><key>CFBundleExecutable</key><string>Inner</string></dict>",
|
||||
"<key>CFBundleExecutable</key><string>App</string>",
|
||||
"</dict></plist>",
|
||||
].join(""),
|
||||
);
|
||||
await writeFile(executable, thinMach(0xfeedfacf, 0x0100000c));
|
||||
await writeFile(
|
||||
join(contents, "MacOS", "Old"),
|
||||
thinMach(0xfeedfacf, 0x0100000c),
|
||||
);
|
||||
await writeFile(
|
||||
join(contents, "MacOS", "Inner"),
|
||||
thinMach(0xfeedfacf, 0x0100000c),
|
||||
);
|
||||
const result = await parseBinaryTarget(app, directory, "arm64");
|
||||
expect(result.ok && result.value).toMatchObject({
|
||||
path: await realpath(executable),
|
||||
});
|
||||
});
|
||||
|
||||
it.skipIf(process.platform !== "darwin")(
|
||||
"preserves executable filename whitespace from native binary plists",
|
||||
async () => {
|
||||
|
||||
Reference in New Issue
Block a user