From 57f32a269a06ec5102b08824d251afa5456d4195 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 13 May 2021 09:27:56 +0200 Subject: only allow a single injection payload for page, rely on script bags for complex payloads --- background/main.js | 10 +++++++--- background/page_actions_server.js | 3 ++- background/reverse_use_info.js | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'background') diff --git a/background/main.js b/background/main.js index 6b636c4..6656284 100644 --- a/background/main.js +++ b/background/main.js @@ -110,7 +110,11 @@ components.push([TYPE_PREFIX.SCRIPT, name]); } - await storage.set(TYPE_PREFIX.PAGE, "https://my.fsf.org/join", {components}); + await storage.set(TYPE_PREFIX.BAG, "myfsf_join", components); + + await storage.set(TYPE_PREFIX.PAGE, "https://my.fsf.org/join", { + components: [TYPE_PREFIX.BAG, "myfsf_join"] + }); let hello_script = { text: "console.log(\"hello, every1!\");\n" @@ -119,7 +123,7 @@ await storage.set(TYPE_PREFIX.BAG, "hello", [[TYPE_PREFIX.SCRIPT, "hello"]]); await storage.set(TYPE_PREFIX.PAGE, "https://my.fsf.org/", { - components: [[TYPE_PREFIX.BAG, "hello"]], + components: [TYPE_PREFIX.BAG, "hello"], allow: true }); @@ -157,7 +161,7 @@ for (let prop of data.props.pageProps.list) { await storage.set(TYPE_PREFIX.SCRIPT, "opencores", opencores_script); await storage.set(TYPE_PREFIX.PAGE, "https://opencores.org/projects", { - components: [[TYPE_PREFIX.SCRIPT, "opencores"]], + components: [TYPE_PREFIX.SCRIPT, "opencores"], allow: false }); } diff --git a/background/page_actions_server.js b/background/page_actions_server.js index 2a0b858..2dfcf9a 100644 --- a/background/page_actions_server.js +++ b/background/page_actions_server.js @@ -31,7 +31,8 @@ let components = settings.components; let processed_bags = new Set(); - send_scripts_rec(components, port, processed_bags); + if (components !== undefined) + send_scripts_rec([components], port, processed_bags); } // TODO: parallelize script fetching diff --git a/background/reverse_use_info.js b/background/reverse_use_info.js index 688cd64..c51d06b 100644 --- a/background/reverse_use_info.js +++ b/background/reverse_use_info.js @@ -10,6 +10,12 @@ "use strict"; +/* + * Warning! + * This script file has not been used for some time and underlying storage + * model has changed since then! Fix required! + */ + /* * We want to count referenes to scripts and bags in order to know, * for example, whether one can be safely deleted. -- cgit v1.2.3