Skip to content

Commit

Permalink
ensure only valid keys are used
Browse files Browse the repository at this point in the history
  • Loading branch information
doowb committed Jun 24, 2019
1 parent ede8cbe commit cb12f14
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(obj, prop, val) {
return obj;
}

var keys = split(prop, {sep: '.', brackets: true});
var keys = split(prop, {sep: '.', brackets: true}).filter(isValidKey);
var len = keys.length;
var idx = -1;
var current = obj;
Expand All @@ -49,3 +49,7 @@ module.exports = function(obj, prop, val) {

return obj;
};

function isValidKey(key) {
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
}

0 comments on commit cb12f14

Please sign in to comment.