1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-06-26 08:40:05 +02:00

Block data URLs instead of their requests

Fixes #211
This commit is contained in:
kkapsner 2018-07-21 00:32:15 +02:00
parent 0ce446cf52
commit 9ba9c48422
6 changed files with 25 additions and 33 deletions

View File

@ -725,12 +725,12 @@
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_title": { "blockDataURLs_title": {
"message": "Anfragen von Data-URL Seiten blockieren", "message": "Data-URL Seiten blockieren",
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_description": { "blockDataURLs_description": {
"message": "Data-URL Seiten können nicht gegen Fingerprinting geschützt werden (siehe https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Indem Anfragen von Data-URL Seiten blockiert werden kann verhindert werden, dass der echte Fingerabdruck zu irgendeinem Server gelangt.", "message": "Data-URL Seiten können nicht gegen Fingerprinting geschützt werden (siehe https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Indem Data-URL Seiten blockiert werden kann verhindert werden, dass der echte Fingerabdruck zu irgendeinem Server gelangt.",
"description": "" "description": ""
}, },

View File

@ -725,12 +725,12 @@
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_title": { "blockDataURLs_title": {
"message": "Block requests from data URL pages", "message": "Block data URL pages",
"description": "" "description": ""
}, },
"blockRequestsFromDataURL_description": { "blockDataURLs_description": {
"message": "Data URL pages cannot be protected against fingerprinting (see https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Blocking requests from them prevents the real fingerprint to reach any server.", "message": "Data URL pages cannot be protected against fingerprinting (see https://bugzilla.mozilla.org/show_bug.cgi?id=1475831). Blocking them prevents the real fingerprint to reach any server.",
"description": "" "description": ""
}, },

View File

@ -16,34 +16,25 @@
const logging = require("./logging"); const logging = require("./logging");
const settings = require("./settings"); const settings = require("./settings");
const dataUrlFrames = new Set();
scope.init = function(){ scope.init = function(){
browser.webRequest.onBeforeRequest.addListener( browser.webRequest.onHeadersReceived.addListener(
function(details){ function(details){
if ( const headers = details.responseHeaders;
details.url.startsWith("data:text") if (settings.blockDataURLs){
){ logging.verbose("Adding CSP header to", details);
dataUrlFrames.add(details.frameId); headers.push({
logging.message("Detected data URL", details); name: "Content-Security-Policy",
} value: "object-src *; child-src *"
else if ( });
settings.blockRequestsFromDataURL &&
dataUrlFrames.has(details.frameId)
){
logging.warning("Blocking request from data-URL frame.", details);
if (
settings.get("showNotifications")
){
browser.pageAction.show(details.tabId);
}
return {cancel: true};
} }
return {
responseHeaders: headers
};
}, },
{ {
urls: ["<all_urls>"] urls: ["<all_urls>"]
}, },
["blocking"] ["blocking", "responseHeaders"]
); );
}; };

View File

@ -206,7 +206,7 @@
} }
}, },
{ {
name: "blockRequestsFromDataURL", name: "blockDataURLs",
defaultValue: true defaultValue: true
}, },
{ {

View File

@ -381,7 +381,7 @@
}, },
"misc", "misc",
{ {
"name": "blockRequestsFromDataURL", "name": "blockDataURLs",
"displayDependencies": { "displayDependencies": {
"displayAdvancedSettings": [true] "displayAdvancedSettings": [true]
} }

View File

@ -1,15 +1,16 @@
Version 0.5.1: Version 0.5.1:
changes: changes:
- - instead of blocking requests from data URLs they are blocked themselfes
new features: new features:
- new setting: session white list that is cleared on addon load (= browser start) - new setting: session white list that is cleared on addon load (= browser start)
fixes: fixes:
- Changes made in the page action were not saved in all Firefox versions - Changes made in the page action were not saved in all Firefox versions
- Blocking requests data URLs blocked too much
known issues: known issues:
- if a data URL request is blocked the page action button appears but shows no content - if a data URL is blocked the page action button does not appear
Version 0.5.0.1b: Version 0.5.0.1b:
known issues: known issues: