forked from svrjs/svrjs
Make deepClone create a null prototype object, and make process.serverConfig a null prototype object.
This commit is contained in:
parent
4b37e08bb5
commit
5bd369e38d
2 changed files with 3 additions and 3 deletions
|
@ -225,7 +225,7 @@ if (fs.existsSync(process.dirname + "/config.json")) {
|
||||||
try {
|
try {
|
||||||
configJSONf = fs.readFileSync(process.dirname + "/config.json"); // Read JSON File
|
configJSONf = fs.readFileSync(process.dirname + "/config.json"); // Read JSON File
|
||||||
try {
|
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) {
|
} catch (err2) {
|
||||||
configJSONPErr = err2;
|
configJSONPErr = err2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Function to deep clone an object or array
|
// Function to deep clone an object or array
|
||||||
function deepClone(obj) {
|
function deepClone(obj, isFullObject) {
|
||||||
if (typeof obj !== "object" || obj === null) {
|
if (typeof obj !== "object" || obj === null) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ function deepClone(obj) {
|
||||||
});
|
});
|
||||||
return clone;
|
return clone;
|
||||||
} else {
|
} else {
|
||||||
const clone = {};
|
const clone = isFullObject ? {} : Object.create(null);
|
||||||
objectsArray.push(obj);
|
objectsArray.push(obj);
|
||||||
clonesArray.push(clone);
|
clonesArray.push(clone);
|
||||||
Object.keys(obj).forEach((key) => {
|
Object.keys(obj).forEach((key) => {
|
||||||
|
|
Reference in a new issue