1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Race condition causes persistent rnd separation between containers to lea

Fixes #369
This commit is contained in:
kkapsner 2019-06-14 10:51:26 +02:00
parent 03524fd789
commit ea15fabad9
3 changed files with 20 additions and 5 deletions

View file

@ -63,6 +63,7 @@
};
const settings = require("./settings");
const logging = require("./logging");
const extension = require("./extension");
function getDomain(window){
@ -81,7 +82,7 @@
}
var persistentRnd = Object.create(null);
let cookieStoreId = "";
let cookieStoreId = false;
settings.onloaded(function(){
try {
let storedData = JSON.parse(
@ -121,6 +122,18 @@
});
return function getPersistentRnd(window){
while (cookieStoreId === false){
logging.message("Starting synchronous request to wait for cookie store id.");
try {
let xhr = new XMLHttpRequest();
xhr.open("GET", "https://[::]", false);
xhr.send();
xhr = null;
}
catch (e){
logging.verbose("Error in XHR:", e);
}
}
var domain = cookieStoreId + getDomain(window);
if (!persistentRnd[domain]){
// create the (sub-)domains random numbers if not existing
@ -144,10 +157,7 @@
persistentRnd[domain] = new Uint8Array(rnd);
};
scope.persistent.setCookieStoreId = function(newCookieStoreId){
if (
typeof newCookieStoreId === "string" &&
newCookieStoreId !== "firefox-default"
){
if (typeof newCookieStoreId === "string"){
cookieStoreId = (
newCookieStoreId !== "" &&
newCookieStoreId !== "firefox-default"