Skip to content

Commit

Permalink
Merge pull request #240 from AmazingMech2418/patch-1
Browse files Browse the repository at this point in the history
Fix #239
  • Loading branch information
richardgirges committed Aug 6, 2020
2 parents fd40389 + 1530cf5 commit 9fca550
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/processNested.js
@@ -1,4 +1,6 @@
const INVALID_KEYS = ['__proto__', 'constructor'];
const OBJECT_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Object.prototype);
const ARRAY_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Array.prototype);


module.exports = function(data){
if (!data || data.length < 1) return {};
Expand All @@ -19,7 +21,8 @@ module.exports = function(data){
let k = keyParts[index];

// Ensure we don't allow prototype pollution
if (INVALID_KEYS.includes(k)) {
const IN_ARRAY_PROTOTYPE = ARRAY_PROTOTYPE_KEYS.includes(k) && Array.isArray(current);
if (OBJECT_PROTOTYPE_KEYS.includes(k) || IN_ARRAY_PROTOTYPE) {
continue;
}

Expand All @@ -32,5 +35,7 @@ module.exports = function(data){
}
}



return d;
};
};

0 comments on commit 9fca550

Please sign in to comment.