2018-07-16 00:14:44 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
(function(){
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var scope;
|
|
|
|
if ((typeof exports) !== "undefined"){
|
|
|
|
scope = exports;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.scope.dataUrls = {};
|
|
|
|
scope = window.scope.dataUrls;
|
|
|
|
}
|
|
|
|
|
|
|
|
const logging = require("./logging");
|
|
|
|
const settings = require("./settings");
|
|
|
|
|
|
|
|
scope.init = function(){
|
2018-07-21 13:25:15 +02:00
|
|
|
const cspMatch = "blob: filesystem: *";
|
2018-07-21 00:32:15 +02:00
|
|
|
browser.webRequest.onHeadersReceived.addListener(
|
2018-07-16 00:14:44 +02:00
|
|
|
function(details){
|
2018-07-21 00:32:15 +02:00
|
|
|
const headers = details.responseHeaders;
|
|
|
|
if (settings.blockDataURLs){
|
|
|
|
logging.verbose("Adding CSP header to", details);
|
|
|
|
headers.push({
|
|
|
|
name: "Content-Security-Policy",
|
2018-07-21 13:25:15 +02:00
|
|
|
value: `object-src ${cspMatch}; frame-src ${cspMatch}; worker-src ${cspMatch}`
|
2018-07-21 00:32:15 +02:00
|
|
|
});
|
2018-07-16 00:14:44 +02:00
|
|
|
}
|
2018-07-21 00:32:15 +02:00
|
|
|
return {
|
|
|
|
responseHeaders: headers
|
|
|
|
};
|
2018-07-16 00:14:44 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
urls: ["<all_urls>"]
|
|
|
|
},
|
2018-07-21 00:32:15 +02:00
|
|
|
["blocking", "responseHeaders"]
|
2018-07-16 00:14:44 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|