summaryrefslogtreecommitdiff
path: root/src/bg/RequestGuard.js
diff options
context:
space:
mode:
authorhackademix2018-07-06 04:01:44 +0200
committerhackademix2018-07-06 04:01:44 +0200
commit093b9d724ecfe22989f6f68ac8114b5dfa639360 (patch)
treee916efc5930e47850011c7007318d25de9636433 /src/bg/RequestGuard.js
parent799d99bd1019984a59394e4646f85afe9efc53f2 (diff)
downloadnoscript-093b9d724ecfe22989f6f68ac8114b5dfa639360.tar.gz
noscript-093b9d724ecfe22989f6f68ac8114b5dfa639360.tar.xz
noscript-093b9d724ecfe22989f6f68ac8114b5dfa639360.zip
Work-around for onload not being fired on XML documents in Tor Browser/ESR60.
Diffstat (limited to 'src/bg/RequestGuard.js')
-rw-r--r--src/bg/RequestGuard.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index 3304d02..b23853f 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -355,10 +355,11 @@ var RequestGuard = (() => {
async onHeadersReceived(request) {
// called for main_frame, sub_frame and object
debug("onHeadersReceived", request);
+ let {url, documentUrl, statusCode, tabId, responseHeaders} = request;
+ if (statusCode >= 300 && statusCode < 400) return;
try {
let header, blocker;
- let responseHeaders = request.responseHeaders;
let content = {}
for (let h of responseHeaders) {
if (CSP.isMine(h)) {
@@ -370,11 +371,11 @@ var RequestGuard = (() => {
}
- if (ns.isEnforced(request.tabId)) {
+ if (ns.isEnforced(tabId)) {
let policy = ns.policy;
- let perms = policy.get(request.url, request.documentUrl).perms;
+ let perms = policy.get(url, documentUrl).perms;
if (policy.autoAllowTop && request.frameId === 0 && perms === policy.DEFAULT) {
- policy.set(Sites.optimalKey(request.url), perms = policy.TRUSTED.tempTwin);
+ policy.set(Sites.optimalKey(url), perms = policy.TRUSTED.tempTwin);
}
let {capabilities} = perms;
@@ -422,7 +423,7 @@ var RequestGuard = (() => {
}
}
- debug(`CSP blocker on %s:`, request.url, blocker);
+ debug(`CSP blocker on %s:`, url, blocker);
if (blocker) {
if (header) {
header.value = CSP.inject(header.value, blocker);