From 5bd369e38de94325bf88a44b751f37296151a568 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Wed, 28 Aug 2024 07:20:28 +0200 Subject: [PATCH] Make deepClone create a null prototype object, and make process.serverConfig a null prototype object. --- src/index.js | 2 +- src/utils/deepClone.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 4f1becb..a73c3bf 100644 --- a/src/index.js +++ b/src/index.js @@ -225,7 +225,7 @@ if (fs.existsSync(process.dirname + "/config.json")) { try { configJSONf = fs.readFileSync(process.dirname + "/config.json"); // Read JSON File try { - process.serverConfig = JSON.parse(configJSONf); // Parse JSON + process.serverConfig = Object.assign(Object.create(null), JSON.parse(configJSONf)); // Parse JSON and assign it to null prototype object } catch (err2) { configJSONPErr = err2; } diff --git a/src/utils/deepClone.js b/src/utils/deepClone.js index 133e737..e3c7504 100644 --- a/src/utils/deepClone.js +++ b/src/utils/deepClone.js @@ -1,5 +1,5 @@ // Function to deep clone an object or array -function deepClone(obj) { +function deepClone(obj, isFullObject) { if (typeof obj !== "object" || obj === null) { return obj; } @@ -31,7 +31,7 @@ function deepClone(obj) { }); return clone; } else { - const clone = {}; + const clone = isFullObject ? {} : Object.create(null); objectsArray.push(obj); clonesArray.push(clone); Object.keys(obj).forEach((key) => {