File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -230,11 +230,11 @@ function escapeUnsafeChars(str: string) {
230
230
}
231
231
232
232
function safeKey ( key : string ) {
233
- return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key ) ? key : JSON . stringify ( escapeUnsafeChars ( key ) ) ;
233
+ return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key ) ? key : escapeUnsafeChars ( JSON . stringify ( key ) ) ;
234
234
}
235
235
236
236
function safeProp ( key : string ) {
237
- return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key ) ? `.${ key } ` : `[${ JSON . stringify ( escapeUnsafeChars ( key ) ) } ]` ;
237
+ return / ^ [ _ $ a - z A - Z ] [ _ $ a - z A - Z 0 - 9 ] * $ / . test ( key ) ? `.${ key } ` : `[${ escapeUnsafeChars ( JSON . stringify ( key ) ) } ]` ;
238
238
}
239
239
240
240
function stringifyString ( str : string ) {
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ describe('devalue', () => {
91
91
test (
92
92
'Dangerous key' ,
93
93
{ '<svg onload=alert("xss_works")>' : 'bar' } ,
94
- '{"\\\\ u003Csvg onload=alert(\\"xss_works\\")\\ \\u003E":"bar"}'
94
+ '{"\\u003Csvg onload=alert(\\"xss_works\\")\\u003E":"bar"}'
95
95
)
96
96
} ) ;
97
97
You can’t perform that action at this time.
0 commit comments