diff --git a/index.js b/index.js index 388a963..3b13f44 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ module.exports = function (args, opts) { var o = obj; keys.slice(0,-1).forEach(function (key) { if (o[key] === undefined) o[key] = {}; + if (o[key] === {}.__proto__) o[key] = {}; o = o[key]; }); diff --git a/test/proto.js b/test/proto.js index 015ea60..87490c3 100644 --- a/test/proto.js +++ b/test/proto.js @@ -4,5 +4,6 @@ var test = require('tape'); test('proto pollution', function (t) { var argv = parse(['--__proto__.x','123']); t.equal({}.x, undefined); + t.equal(argv.__proto__.x, 123); t.end(); });