From f9703b2bcb2e72de1822ec58aa78ea62b7947783 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sat, 13 Oct 2018 23:13:58 +0200 Subject: Fixed potential race condition in per-tab configuration cookie hack. --- src/content/staticNS.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/content') diff --git a/src/content/staticNS.js b/src/content/staticNS.js index c746180..6002bfd 100644 --- a/src/content/staticNS.js +++ b/src/content/staticNS.js @@ -52,13 +52,14 @@ // (before any content can access it) if (this.config.MARKER = MARKER) { - let cookieRx = new RegExp(`(?:^|;\\s*)${MARKER}=([^;]*)`); + let cookieRx = new RegExp(`(?:^|;\\s*)(${MARKER}(?:_\\d+){2})=([^;]*)`); let match = document.cookie.match(cookieRx); if (match) { + let [cookie, cookieName, cookieValue] = match; // delete cookie NOW - document.cookie = `${MARKER}=;expires=${new Date(Date.now() - 31536000000).toGMTString()}`; + document.cookie = `${cookieName}=;expires=${new Date(Date.now() - 31536000000).toGMTString()}`; try { - this.config.tabInfo = JSON.parse(decodeURIComponent(match[1])); + this.config.tabInfo = JSON.parse(decodeURIComponent(cookieValue)); } catch (e) { error(e); } -- cgit v1.2.3