[TabGuard] Exclude non-scriptable content types from suspects.

This commit is contained in:
hackademix 2023-06-22 23:04:13 +02:00
parent 73da318de5
commit c46b2eebce
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
1 changed files with 16 additions and 0 deletions

View File

@ -178,6 +178,22 @@ var TabGuard = (() => {
if (!ns.policy.can(tab.url, "script")) return;
}
}
if (!tab._contentType) {
try {
tab._contentType = await browser.tabs.executeScript(tab.id, {
runAt: "document_start",
code: "document.contentType"
});
} catch (e) {
// We don't have permissions to run in this tab: privileged!
debug(e);
return;
}
}
if (!/(?:(?:x|ht)ml|svg)\b/i.test(tab._contentType)) {
// not a scripting-capable document - maybe a PDF?
return;
}
suspiciousDomains.push(getDomain(tab.url));
}));