Skip to content

Commit 9fca550

Browse files
Merge pull request #240 from AmazingMech2418/patch-1
Fix #239
2 parents fd40389 + 1530cf5 commit 9fca550

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/processNested.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const INVALID_KEYS = ['__proto__', 'constructor'];
1+
const OBJECT_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Object.prototype);
2+
const ARRAY_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Array.prototype);
3+
24

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

2123
// Ensure we don't allow prototype pollution
22-
if (INVALID_KEYS.includes(k)) {
24+
const IN_ARRAY_PROTOTYPE = ARRAY_PROTOTYPE_KEYS.includes(k) && Array.isArray(current);
25+
if (OBJECT_PROTOTYPE_KEYS.includes(k) || IN_ARRAY_PROTOTYPE) {
2326
continue;
2427
}
2528

@@ -32,5 +35,7 @@ module.exports = function(data){
3235
}
3336
}
3437

38+
39+
3540
return d;
36-
};
41+
};

0 commit comments

Comments
 (0)