Bug 1965726 - Avoid throwing on non-string registry keys for native manifests r=robwu

Differential Revision: https://phabricator.services.mozilla.com/D248944
This commit is contained in:
Tomislav Jovanovic
2025-05-13 23:17:04 +00:00
committed by tjovanovic@mozilla.com
parent 5a3e60d1f4
commit 879055e020
2 changed files with 38 additions and 0 deletions

View File

@@ -81,6 +81,12 @@ export var NativeManifests = {
if (!path) {
return null;
}
if (typeof path !== "string") {
Cu.reportError(
`Native manifest registry entry ${regPath} must be a string path`
);
return null;
}
// Normalize in case the extension used / instead of \.
path = path.replaceAll("/", "\\");

View File

@@ -296,6 +296,38 @@ add_task(async function test_nonexistent_manifest_with_registry_entry() {
}
});
add_task(
{ skip_if: () => AppConstants.platform !== "win" },
async function test_nonstring_registry_entry() {
registry.setValue(
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
`${REGPATH}\\test`,
"",
42,
Ci.nsIWindowsRegKey.TYPE_INT
);
let { messages, result } = await promiseConsoleOutput(() =>
lookupApplication("test", context)
);
equal(
null,
result,
"lookupApplication returns null for non-string registry key"
);
let typeErrors = messages.filter(log =>
log.message.includes(`registry entry ${REGPATH}\\test must be a string`)
);
equal(
1,
typeErrors.length,
"lookupApplication logs an error for a non-string registry entry"
);
}
);
add_task(async function test_good_manifest() {
await writeManifest(USER_TEST_JSON, templateManifest);
if (registry) {