Skip to content

Commit 09c4b10

Browse files
committed
back port patch for 4.0.1
1 parent 8353e4d commit 09c4b10

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ function createKey(pattern, options) {
9999
}
100100

101101
function isValidKey(key) {
102+
if (typeof key !== 'string' && typeof key !== 'number') {
103+
key = String(key);
104+
}
105+
102106
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
103107
}
104108

test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,12 @@ describe('options', function() {
210210
assert.equal(o.a['{b.c.d}'].e, 'c');
211211
});
212212
});
213+
214+
describe('patches', function() {
215+
it('should not allow setting an unsafe key', function() {
216+
const o = {};
217+
assert.equal({}.foo, undefined);
218+
set(o, [['__proto__'], 'foo'], 'bar');
219+
assert.equal({}.foo, undefined);
220+
});
221+
});

0 commit comments

Comments
 (0)