File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ function createKey(pattern, options) {
99
99
}
100
100
101
101
function isValidKey ( key ) {
102
+ if ( typeof key !== 'string' && typeof key !== 'number' ) {
103
+ key = String ( key ) ;
104
+ }
105
+
102
106
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype' ;
103
107
}
104
108
Original file line number Diff line number Diff line change @@ -210,3 +210,12 @@ describe('options', function() {
210
210
assert . equal ( o . a [ '{b.c.d}' ] . e , 'c' ) ;
211
211
} ) ;
212
212
} ) ;
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments