Skip to content

Commit 1337108

Browse files
Update index.js
Co-authored-by: Tom Spencer <[email protected]>
1 parent 2da4cc5 commit 1337108

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ module.exports = function (bodyParser) {
4444
}
4545

4646
// Prevent setting __proto__ and constructor.prototype
47-
const safe = {};
48-
for (const key in xml) {
49-
if (
50-
key !== '__proto__' &&
51-
key !== 'constructor' &&
52-
key !== 'prototype'
53-
) {
54-
safe[key] = xml[key];
55-
}
47+
if(xml) {
48+
// Guard against prototype pollution
49+
delete xml.__proto__;
50+
delete xml.constructor;
51+
delete xml.prototype;
52+
53+
req.body = xml;
5654
}
57-
req.body = safe || req.body;
5855
next();
5956
});
6057
});

0 commit comments

Comments
 (0)