Gracefully handle new capabilities still unknown to the settings host (e.g. Tor/Mullvad browser), if any.

This commit is contained in:
hackademix 2024-08-24 11:27:50 +02:00
parent 07db46a909
commit 06b9b455bc
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
1 changed files with 20 additions and 0 deletions

View File

@ -103,6 +103,7 @@ var Settings = {
unrestrictedTab,
reloadAffected,
isTorBrowser,
settingsHost,
} = settings;
debug("Received settings ", settings);
let oldDebug = ns.local.debug;
@ -130,6 +131,25 @@ var Settings = {
reloadOptionsUI = true;
}
if (policy && policy.TRUSTED) {
// Gracefully handle "new" capabilities still unknown to our settings host
const knownCapabilities = settingsHost && settingsHost.knownCapabilities
|| policy.TRUSTED.capabilities;
for (const cap of ["lazy_load", "unchecked_css"]) {
// Scripting far exceeds the security/privacy concerns around these capabilities,
// so enable them on script-capable presets unless our settingsHost knows better.
if (cap in knownCapabilities) continue;
for (const preset of ["TRUSTED", "UNTRUSTED", "DEFAULT"]) {
if (!policy[preset]) continue;
const {capabilities} = policy[preset];
if (capabilities.includes("script") && !capabilities.includes(cap)) {
capabilities.push(cap);
}
}
}
}
let torBrowserSettings = {
local: {
isTorBrowser: true,