1
0
Fork 0
forked from svrjs/svrjs

Make deepClone create a null prototype object, and make process.serverConfig a null prototype object.

This commit is contained in:
Dorian Niemiec 2024-08-28 07:20:28 +02:00
parent 4b37e08bb5
commit 5bd369e38d
2 changed files with 3 additions and 3 deletions

View file

@ -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;
}

View file

@ -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) => {