Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e6cbd4f

Browse files
lgalfasopetebacondarwin
authored andcommittedSep 14, 2015
fix($parse): throw error when accessing a restricted property indirectly
When accessing an instance thru a computed member and the property is an array, then also check the string value of the array. Closes #12833
1 parent fccce96 commit e6cbd4f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎src/ng/parse.js

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ var promiseWarning;
2929

3030

3131
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+
3241
if (name === "__defineGetter__" || name === "__defineSetter__"
3342
|| name === "__lookupGetter__" || name === "__lookupSetter__"
3443
|| name === "__proto__") {

‎test/ng/parseSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,20 @@ describe('parser', function() {
987987
scope.$eval('{}["__proto__"].foo = 1');
988988
}).toThrowMinErr('$parse', 'isecfld');
989989

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+
9901004
scope.a = "__pro";
9911005
scope.b = "to__";
9921006
expect(function() {

0 commit comments

Comments
 (0)
This repository has been archived.