From cb12f14955dde6e61829d70d1851bfea6a3c31ad Mon Sep 17 00:00:00 2001 From: doowb Date: Mon, 24 Jun 2019 16:59:09 -0400 Subject: [PATCH] ensure only valid keys are used --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 000a77e..0b32e8f 100644 --- a/index.js +++ b/index.js @@ -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; @@ -49,3 +49,7 @@ module.exports = function(obj, prop, val) { return obj; }; + +function isValidKey(key) { + return key !== '__proto__' && key !== 'constructor' && key !== 'prototype'; +}