diff options
author | hackademix | 2018-07-07 01:28:20 +0200 |
---|---|---|
committer | hackademix | 2018-07-07 01:28:20 +0200 |
commit | 0ad5f95eb479f8450058333541631640fc8ee4bb (patch) | |
tree | ce3d5029a07f26579c53750e5e868f5f3684cdb5 /src/bg | |
parent | 093b9d724ecfe22989f6f68ac8114b5dfa639360 (diff) | |
download | noscript-0ad5f95eb479f8450058333541631640fc8ee4bb.tar.gz noscript-0ad5f95eb479f8450058333541631640fc8ee4bb.tar.xz noscript-0ad5f95eb479f8450058333541631640fc8ee4bb.zip |
Fixed dynamic script injection breaking images shown as frame content.
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/RequestGuard.js | 23 | ||||
-rw-r--r-- | src/bg/RequestUtil.js | 9 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index b23853f..dcb79a7 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -90,9 +90,6 @@ var RequestGuard = (() => { if (what === "noscriptFrame") { let nsf = records.noscriptFrames; - if (frameId in nsf) { - return null; - } nsf[frameId] = optValue; what = optValue ? "blocked" : "allowed"; if (frameId === 0) { @@ -278,18 +275,20 @@ var RequestGuard = (() => { }; if (tabId < 0) return; if (pending) request.initialUrl = pending.initialUrl; - try { - browser.tabs.sendMessage( - tabId, - {type: "seen", request, allowed, policyType, ownFrame: true}, - {frameId} - ); - } catch (e) { - debug(`Couldn't deliver "seen" message for ${type}@${url} ${allowed ? "A" : "F" } to document ${documentUrl} (${frameId}/${tabId}`, e); + if (type !== "sub_frame") { // we couldn't deliver it to frameId, since it's generally not loaded yet + try { + await browser.tabs.sendMessage( + tabId, + {type: "seen", request, allowed, policyType, ownFrame: true}, + {frameId} + ); + } catch (e) { + debug(`Couldn't deliver "seen" message for ${type}@${url} ${allowed ? "A" : "F" } to document ${documentUrl} (${frameId}/${tabId})`, e); + } } if (frameId === 0) return; try { - browser.tabs.sendMessage( + await browser.tabs.sendMessage( tabId, {type: "seen", request, allowed, policyType}, {frameId: 0} diff --git a/src/bg/RequestUtil.js b/src/bg/RequestUtil.js index d010f2b..39b1bf7 100644 --- a/src/bg/RequestUtil.js +++ b/src/bg/RequestUtil.js @@ -1,6 +1,7 @@ 'use strict'; { let NULL = new Uint8Array(); + let brokenOnLoad = (async () => parseInt(await browser.runtime.getBrowserInfo().version) < 61); let pendingRequests = new Map(); let cleanup = r => { @@ -59,7 +60,7 @@ let content = this.getContentMetaData(request); debug(request.url, content.type); - if (/\bxml\b/.test(content.type) && !/\bhtml\b/.test(content.type)) return; + if (/^[\w/+-]*\b(xml|image)\b/i.test(content.type) && !/\bhtml\b/i.test(content.type)) return; let filter = browser.webRequest.filterResponseData(requestId); let buffer = []; @@ -76,8 +77,10 @@ } }; - filter.onstart = event => { - filter.write(NULL); + if (brokenOnLoad) { + filter.onstart = event => { + filter.write(NULL); + } } filter.ondata = event => { |