From 4d768fd23677ccfbf4d5b5c67a6395644e6890be Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Tue, 25 May 2021 14:53:06 +0100 Subject: [PATCH] ensure context get/set key is a string --- .../@node-red/runtime/lib/nodes/context/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/context/index.js b/packages/node_modules/@node-red/runtime/lib/nodes/context/index.js index fda3852ff..56b0c7e6f 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/context/index.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/context/index.js @@ -256,6 +256,9 @@ function createContext(id,seed,parent) { value: function(key, storage, callback) { var context; + if (typeof key !== "string" || !key.length) { + throw new Error("context get() requires 'key' to be a valid string"); + } if (!callback && typeof storage === 'function') { callback = storage; storage = undefined; @@ -338,6 +341,9 @@ function createContext(id,seed,parent) { value: function(key, value, storage, callback) { var context; + if (typeof key !== "string" || !key.length) { + throw new Error("context set() requires 'key' to be a valid string"); + } if (!callback && typeof storage === 'function') { callback = storage; storage = undefined;