diff options
author | hackademix | 2018-12-26 23:44:36 +0100 |
---|---|---|
committer | hackademix | 2018-12-26 23:44:36 +0100 |
commit | 357906df784f62858e38826df6f995dc55bbbcad (patch) | |
tree | abac94860507eac4b401603368ce815edeef2404 /src/content/staticNS.js | |
parent | f341217e0afd14967160f5983f20e3e5cbba99f6 (diff) | |
download | noscript-357906df784f62858e38826df6f995dc55bbbcad.tar.gz noscript-357906df784f62858e38826df6f995dc55bbbcad.tar.xz noscript-357906df784f62858e38826df6f995dc55bbbcad.zip |
Fix for unrestricted tabs not affecting about:blank subframes (issue #48).
Diffstat (limited to 'src/content/staticNS.js')
-rw-r--r-- | src/content/staticNS.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/content/staticNS.js b/src/content/staticNS.js index 6002bfd..0cd254c 100644 --- a/src/content/staticNS.js +++ b/src/content/staticNS.js @@ -51,7 +51,9 @@ // to store per-tab information, erasing it as soon as we see it // (before any content can access it) - if (this.config.MARKER = MARKER) { + let checkUnrestricted = challenge => sha256(`${MARKER}:${challenge}`); + + if ((this.config.MARKER = MARKER) && permissions) { let cookieRx = new RegExp(`(?:^|;\\s*)(${MARKER}(?:_\\d+){2})=([^;]*)`); let match = document.cookie.match(cookieRx); if (match) { @@ -63,9 +65,21 @@ } catch (e) { error(e); } + } else if (window !== window.top) { + // The cookie hack won't work for non-HTTP subframes (issue #48), + // or the cookie might have been deleted in a race condition, + // so here we try to check the parent + let checkParent = parent.wrappedJSObject.checkNoScriptUnrestricted; + if (checkParent) { + let challenge = uuid(); + let unrestricted = checkParent(challenge) === checkUnrestricted(challenge); + this.config.tabInfo = {unrestricted, inherited: true}; + } } } + if (!this.config.permissions || this.config.tabInfo.unrestricted) { + exportFunction(checkUnrestricted, window, {defineAs: "checkNoScriptUnrestricted"}); debug("%s is loading unrestricted by user's choice (%o).", document.URL, this.config); this.allows = () => true; this.capabilities = Object.assign( |