We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fd40389 + 1530cf5 commit 9fca550Copy full SHA for 9fca550
lib/processNested.js
@@ -1,4 +1,6 @@
1
-const INVALID_KEYS = ['__proto__', 'constructor'];
+const OBJECT_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Object.prototype);
2
+const ARRAY_PROTOTYPE_KEYS = Object.getOwnPropertyNames(Array.prototype);
3
+
4
5
module.exports = function(data){
6
if (!data || data.length < 1) return {};
@@ -19,7 +21,8 @@ module.exports = function(data){
19
21
let k = keyParts[index];
20
22
23
// Ensure we don't allow prototype pollution
- 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) {
26
continue;
27
}
28
@@ -32,5 +35,7 @@ module.exports = function(data){
32
35
33
36
34
37
38
39
40
return d;
-};
41
+};
0 commit comments