From ea7dfabb093298bffd75f85377393b21149b78a1 Mon Sep 17 00:00:00 2001 From: hackademix Date: Mon, 3 May 2021 20:16:46 +0200 Subject: [PATCH] Policy retrieval origin fine tuning. --- src/content/staticNS.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/content/staticNS.js b/src/content/staticNS.js index 281ad9d..49c8f09 100644 --- a/src/content/staticNS.js +++ b/src/content/staticNS.js @@ -52,7 +52,7 @@ } } - if (/^(ftp|file):/.test(url)) { // ftp: or file: - no CSP headers yet + if (/^(?:ftp|file):/.test(url)) { // ftp: or file: - no CSP headers yet if (this.syncFetchPolicy) { this.syncFetchPolicy(); } else { // additional content scripts not loaded yet @@ -62,7 +62,9 @@ } } else { // CSP headers have been already provided by webRequest, we are not in a hurry... - if (/^(javascript|about):/.test(url)) { + if (url.startsWith("blob:")) { + url = location.origin; + } else if (/^(?:javascript|about):/.test(url)) { url = document.readyState === "loading" ? document.baseURI : `${window.isSecureContext ? "https" : "http"}://${document.domain}`; @@ -119,5 +121,5 @@ }, }; window.ns = window.ns ? Object.assign(ns, window.ns) : ns; - debug("StaticNS", window.domPolicy, Date.now(), JSON.stringify(window.ns)); // DEV_ONLY + debug("StaticNS", Date.now(), JSON.stringify(window.ns)); // DEV_ONLY }