File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 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');
3838
3939
4040function 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+
4150 if ( name === "__defineGetter__" || name === "__defineSetter__"
4251 || name === "__lookupGetter__" || name === "__lookupSetter__"
4352 || name === "__proto__" ) {
Original file line number Diff line number Diff line change @@ -1190,6 +1190,20 @@ describe('parser', function() {
11901190 scope . $eval ( '{}["__proto__"].foo = 1' ) ;
11911191 } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
11921192
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+
11931207 scope . a = "__pro" ;
11941208 scope . b = "to__" ;
11951209 expect ( function ( ) {
You can’t perform that action at this time.
0 commit comments