From df09b7e0ec483d96b7d477547938f23a82defe59 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sat, 20 May 2017 01:08:19 -0700 Subject: [PATCH] Preclude kitchen configs from mutation --- .../src/extension-common/35-pac-kitchen-api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js index c3bf1c5..de95500 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js @@ -12,8 +12,7 @@ const ifIncontinence = 'if-incontinence'; const modsKey = 'mods'; - // Don't keep objects in defaults or at least freeze them! - const configs = { + const getDefaultConfigs () => {// Configs user may mutate them and we don't care! ifProxyHttpsUrlsOnly: { dflt: false, @@ -93,6 +92,7 @@ const getDefaults = function getDefaults() { + const configs = getDefaultConfigs(); return Object.keys(configs).reduce((acc, key) => { acc[key] = configs[key].dflt; @@ -123,6 +123,7 @@ const getOrderedConfigsForUser = function getOrderedConfigs(category) { const pacMods = getCurrentConfigs(); + const configs = getDefaultConfigs(); return Object.keys(configs) .sort((keyA, keyB) => configs[keyA].order - configs[keyB].order) .reduce((arr, key) => { @@ -144,6 +145,7 @@ const createPacModifiers = function createPacModifiers(mods = {}) { mods = mods || {}; // null? + const configs = getDefaultConfigs(); const ifNoMods = Object.keys(configs) .every((dProp) => {