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 @@ -29,6 +29,15 @@ var promiseWarning;
29
29
30
30
31
31
function ensureSafeMemberName ( name , fullExpression ) {
32
+ // From the JavaScript docs:
33
+ // Property names must be strings. This means that non-string objects cannot be used
34
+ // as keys in an object. Any non-string object, including a number, is typecasted
35
+ // into a string via the toString method.
36
+ //
37
+ // So, to ensure that we are checking the same `name` that JavaScript would use,
38
+ // we cast it to a string, if possible
39
+ name = ( isObject ( name ) && name . toString ) ? name . toString ( ) : name ;
40
+
32
41
if ( name === "__defineGetter__" || name === "__defineSetter__"
33
42
|| name === "__lookupGetter__" || name === "__lookupSetter__"
34
43
|| name === "__proto__" ) {
Original file line number Diff line number Diff line change @@ -987,6 +987,20 @@ describe('parser', function() {
987
987
scope . $eval ( '{}["__proto__"].foo = 1' ) ;
988
988
} ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
989
989
990
+ expect ( function ( ) {
991
+ scope . $eval ( '{}[["__proto__"]]' ) ;
992
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
993
+ expect ( function ( ) {
994
+ scope . $eval ( '{}[["__proto__"]].foo = 1' ) ;
995
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
996
+
997
+ expect ( function ( ) {
998
+ scope . $eval ( '0[["__proto__"]]' ) ;
999
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1000
+ expect ( function ( ) {
1001
+ scope . $eval ( '0[["__proto__"]].foo = 1' ) ;
1002
+ } ) . toThrowMinErr ( '$parse' , 'isecfld' ) ;
1003
+
990
1004
scope . a = "__pro" ;
991
1005
scope . b = "to__" ;
992
1006
expect ( function ( ) {
You can’t perform that action at this time.
0 commit comments