summaryrefslogtreecommitdiff
path: root/src/bg/RequestGuard.js
diff options
context:
space:
mode:
authorhackademix2018-07-22 19:14:54 +0200
committerhackademix2018-07-22 19:14:54 +0200
commit4302246ac01d7dc56650ffa227ad87fe98ccfc03 (patch)
tree2801d4334efecae9885dc3d4a9fcb4056be7a019 /src/bg/RequestGuard.js
parent81b38512568982267b48f6df4ae15fb35ef1cc15 (diff)
downloadnoscript-4302246ac01d7dc56650ffa227ad87fe98ccfc03.tar.gz
noscript-4302246ac01d7dc56650ffa227ad87fe98ccfc03.tar.xz
noscript-4302246ac01d7dc56650ffa227ad87fe98ccfc03.zip
More reliable handling of edge startup cases.
Diffstat (limited to 'src/bg/RequestGuard.js')
-rw-r--r--src/bg/RequestGuard.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index a50b571..6f507fe 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -357,7 +357,7 @@ var RequestGuard = (() => {
// called for main_frame, sub_frame and object
debug("onHeadersReceived", request);
let {url, documentUrl, statusCode, tabId, responseHeaders} = request;
- if (statusCode >= 300 && statusCode < 400) return;
+ //if (statusCode >= 300 && statusCode < 400) return;
try {
let header, blocker;
@@ -421,6 +421,9 @@ var RequestGuard = (() => {
await RequestUtil.executeOnStart(request, {
file: "content/media.js"
});
+ } else if (request.frameId === 0 && !TabStatus.map.has(tabId)) {
+ debug("No TabStatus data yet for noscriptFrame", tabId);
+ TabStatus.record(request, "noscriptFrame", true);
}
}
@@ -442,6 +445,7 @@ var RequestGuard = (() => {
},
onResponseStarted(request) {
+ debug("onResponseStarted", request);
if (request.type === "main_frame") {
TabStatus.initTab(request.tabId);
}
@@ -477,7 +481,7 @@ var RequestGuard = (() => {
let type = report["violated-directive"].split("-", 1)[0]; // e.g. script-src 'none' => script
if (type === "frame") type = "sub_frame";
let url = report['blocked-uri'];
- if (url === 'self') url = request.documentUrl;
+ if (!url || url === 'self') url = request.documentUrl;
return Object.assign({}, request, {
url,
type,
@@ -490,11 +494,12 @@ var RequestGuard = (() => {
const report = JSON.parse(decoder.decode(request.requestBody.raw[0].bytes))['csp-report'];
let csp = report["original-policy"]
debug("CSP report", report);
- if (report['blocked-uri'] !== 'self') {
+ let blockedURI = report['blocked-uri'];
+ if (blockedURI && blockedURI !== 'self') {
let r = fakeRequestFromCSP(report, request);
Content.reportTo(r, false, policyTypesMap[r.type]);
TabStatus.record(r, "blocked");
- } else if (report["violated-directive"] === "script-src 'none'") {
+ } else if (report["violated-directive"] === "script-src" && /; script-src 'none'/.test(report["original-policy"])) {
let r = fakeRequestFromCSP(report, request);
TabStatus.record(r, "noscriptFrame", true);
}