diff options
author | hackademix | 2019-09-29 00:50:43 +0200 |
---|---|---|
committer | hackademix | 2019-09-29 17:29:38 +0200 |
commit | fcd7c4aef0c4b81dafd90ce38f41918ac58da139 (patch) | |
tree | 201c9e99b79e6060df9a477beb91e57d19136b6d /src/bg | |
parent | c3dcf300a60f581cb97ce29a4ba76190cb362604 (diff) | |
download | noscript-fcd7c4aef0c4b81dafd90ce38f41918ac58da139.tar.gz noscript-fcd7c4aef0c4b81dafd90ce38f41918ac58da139.tar.xz noscript-fcd7c4aef0c4b81dafd90ce38f41918ac58da139.zip |
Replace cookie-based hacks with synchronous messaging (currently shimmed) to retrieve fallback and per-tab restriction policies.
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/RequestGuard.js | 6 | ||||
-rw-r--r-- | src/bg/main.js | 22 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index 8d30fe7..3936df9 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -287,8 +287,12 @@ var RequestGuard = (() => { if (policyType) { let {url, originUrl, documentUrl} = request; let isFetch = "fetch" === policyType; + if ((isFetch || "frame" === policyType) && - (((isFetch && !originUrl || url === originUrl) && originUrl === documentUrl + (((isFetch && (!originUrl || + browser.runtime.onSyncMessage && + url.includes(browser.runtime.onSyncMessage.ENDPOINT_PREFIX) + ) || url === originUrl) && originUrl === documentUrl // some extensions make them both undefined, // see https://github.com/eight04/image-picka/issues/150 ) || diff --git a/src/bg/main.js b/src/bg/main.js index ed53603..9c30d4f 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -141,24 +141,26 @@ }, fetchChildPolicy({url, contextUrl}, sender) { - if (!url) url = sender.url; let {tab} = sender; - let tabUrl = tab.url; - if (!contextUrl) contextUrl = tabUrl; - + let topUrl = tab.url || TabCache.get(tab.id); let policy = !Sites.isInternal(url) && ns.isEnforced(tab.id) ? ns.policy : null; - let permissions = Permissions.ALL; + let permissions, unrestricted, cascaded; if (policy) { let perms = policy.get(url, contextUrl).perms; - if (tabUrl && ns.sync.cascadeRestrictions) { - perms = policy.cascadeRestrictions(perms, tabUrl); + cascaded = ns.sync.cascadeRestrictions; + if (topUrl && cascaded) { + perms = policy.cascadeRestrictions(perms, topUrl); } permissions = perms.dry(); - } // otherwise either internal URL or unrestricted - - return {permissions}; + } else { + // otherwise either internal URL or unrestricted + permissions = new Permissions(Permissions.ALL); + unrestricted = true; + cascaded = false; + } + return {permissions, unrestricted, cascaded}; }, async openStandalonePopup() { |