Skip to content

Commit 90ee1fa

Browse files
committed
ensure keys are valid when mixing in values
1 parent a4bcf3e commit 90ee1fa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

index.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function mixinDeep(target, objects) {
2323
*/
2424

2525
function copy(val, key) {
26-
if (key === '__proto__') {
26+
if (!isValidKey(key)) {
2727
return;
2828
}
2929

@@ -46,6 +46,17 @@ function isObject(val) {
4646
return isExtendable(val) && !Array.isArray(val);
4747
}
4848

49+
/**
50+
* Returns true if `key` is a valid key to use when extending objects.
51+
*
52+
* @param {String} `key`
53+
* @return {Boolean}
54+
*/
55+
56+
function isValidKey(key) {
57+
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
58+
};
59+
4960
/**
5061
* Expose `mixinDeep`
5162
*/

0 commit comments

Comments
 (0)