diff options
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/ChildPolicies.js | 2 | ||||
-rw-r--r-- | src/bg/RequestGuard.js | 6 | ||||
-rw-r--r-- | src/bg/main.js | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/bg/ChildPolicies.js b/src/bg/ChildPolicies.js index 5727762..e5024e7 100644 --- a/src/bg/ChildPolicies.js +++ b/src/bg/ChildPolicies.js @@ -190,7 +190,7 @@ getForDocument(policy, url, context = null) { return { - permissions: policy.get(url, context).perms.dry(), + permissions: policy && policy.get(url, context).perms.dry(), MARKER: marker }; }, diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index 0731b7b..c1771aa 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -256,8 +256,8 @@ var RequestGuard = (() => { }); return redirected; } + const ABORT = {cancel: true}, ALLOW = {}; - const INTERNAL_SCHEME = /^(?:chrome|resource|(?:moz|chrome)-extension|about):/; const listeners = { onBeforeRequest(request) { try { @@ -272,7 +272,7 @@ var RequestGuard = (() => { // some extensions make them both undefined, // see https://github.com/eight04/image-picka/issues/150 ) || - INTERNAL_SCHEME.test(originUrl)) + Sites.isInternal(originUrl)) ) { // livemark request or similar browser-internal, always allow; return ALLOW; @@ -281,7 +281,7 @@ var RequestGuard = (() => { request._dataUrl = url; request.url = url = documentUrl; } - let allowed = INTERNAL_SCHEME.test(url) || + let allowed = Sites.isInternal(url) || !ns.isEnforced(request.tabId) || policy.can(url, policyType, originUrl); Content.reportTo(request, allowed, policyType); diff --git a/src/bg/main.js b/src/bg/main.js index 667be28..5d4f79f 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -142,8 +142,10 @@ }, async fetchChildPolicy({url, contextUrl}, sender) { - return ChildPolicies.getForDocument(ns.policy, - url || sender.url, contextUrl || sender.tab.url); + let {tab} = sender; + if (!url) url = sender.url; + let policy = !Sites.isInternal(url) && ns.isEnforced(tab.id) ? ns.policy : null; + return ChildPolicies.getForDocument(policy, url, contextUrl || tab.url); }, async openStandalonePopup() { |