This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ var $parseMinErr = minErr('$parse');
38
38
39
39
40
40
function ensureSafeMemberName ( name , fullExpression ) {
41
+ // From the JavaScript docs:
42
+ // Property names must be strings. This means that non-string objects cannot be used
43
+ // as keys in an object. Any non-string object, including a number, is typecasted
44
+ // into a string via the toString method.
45
+ //
46
+ // So, to ensure that we are checking the same `name` that JavaScript would use,
47
+ // we cast it to a string, if possible
48
+ name = ( isObject ( name ) && name . toString ) ? name . toString ( ) : name ;
49
+
41
50
if ( name === "__defineGetter__" || name === "__defineSetter__"
42
51
|| name === "__lookupGetter__" || name === "__lookupSetter__"
43
52
|| name === "__proto__" ) {
Original file line number Diff line number Diff line change @@ -1190,6 +1190,20 @@ describe('parser', function() {
1190
1190
scope . $eval ( '{}["__proto__"].foo = 1' ) ;
1191
1191
} ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1192
1192
1193
+ expect ( function ( ) {
1194
+ scope . $eval ( '{}[["__proto__"]]' ) ;
1195
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1196
+ expect ( function ( ) {
1197
+ scope . $eval ( '{}[["__proto__"]].foo = 1' ) ;
1198
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1199
+
1200
+ expect ( function ( ) {
1201
+ scope . $eval ( '0[["__proto__"]]' ) ;
1202
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1203
+ expect ( function ( ) {
1204
+ scope . $eval ( '0[["__proto__"]].foo = 1' ) ;
1205
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1206
+
1193
1207
scope . a = "__pro" ;
1194
1208
scope . b = "to__" ;
1195
1209
expect ( function ( ) {
You can’t perform that action at this time.
0 commit comments