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

Commit aaf6226

Browse files
committed
docs($parse/isecac): rename isecaf error to isecac and add missing error page
1 parent 3a6b2b5 commit aaf6226

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@ngdoc error
2+
@name $parse:isecac
3+
@fullName Assigning to Disallowed Context
4+
@description
5+
6+
Occurs when an expression attempts to assign a value on any of the `Boolean`, `Number`, `String`,
7+
`Array`, `Object`, or `Function` constructors or the corresponding prototypes.
8+
9+
Angular bans the modification of these constructors or their prototypes from within expressions,
10+
since it is a known way to modify the behaviour of existing functions/operations.
11+
12+
To resolve this error, avoid modifying the constructors or their prototypes in expressions.

src/ng/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function ensureSafeAssignContext(obj, fullExpression) {
132132
obj === objectConstructor.prototype ||
133133
obj === arrayConstructor.prototype ||
134134
obj === functionConstructor.prototype) {
135-
throw $parseMinErr('isecaf',
135+
throw $parseMinErr('isecac',
136136
'Assigning to a constructor or it\'s prototype is disallowed! Expression: {0}',
137137
fullExpression);
138138
}

test/ng/parseSpec.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -2975,31 +2975,31 @@ describe('parser', function() {
29752975
}).not.toThrow();
29762976
expect(function() {
29772977
scope.$eval(constructorExpr + '.join = ""');
2978-
}).toThrowMinErr('$parse', 'isecaf');
2978+
}).toThrowMinErr('$parse', 'isecac');
29792979
expect(function() {
29802980
scope.$eval(constructorExpr + '[0] = ""');
2981-
}).toThrowMinErr('$parse', 'isecaf');
2981+
}).toThrowMinErr('$parse', 'isecac');
29822982
expect(function() {
29832983
delete scope.foo;
29842984
scope.$eval('foo = ' + constructorExpr + '; foo.join = ""');
2985-
}).toThrowMinErr('$parse', 'isecaf');
2985+
}).toThrowMinErr('$parse', 'isecac');
29862986

29872987
expect(function() {
29882988
scope.foo = thing;
29892989
scope.$eval('foo.constructor[0] = ""');
2990-
}).toThrowMinErr('$parse', 'isecaf');
2990+
}).toThrowMinErr('$parse', 'isecac');
29912991
expect(function() {
29922992
delete scope.foo;
29932993
scope.$eval('foo.constructor[0] = ""', {foo: thing});
2994-
}).toThrowMinErr('$parse', 'isecaf');
2994+
}).toThrowMinErr('$parse', 'isecac');
29952995
expect(function() {
29962996
scope.foo = thing.constructor;
29972997
scope.$eval('foo[0] = ""');
2998-
}).toThrowMinErr('$parse', 'isecaf');
2998+
}).toThrowMinErr('$parse', 'isecac');
29992999
expect(function() {
30003000
delete scope.foo;
30013001
scope.$eval('foo[0] = ""', {foo: thing.constructor});
3002-
}).toThrowMinErr('$parse', 'isecaf');
3002+
}).toThrowMinErr('$parse', 'isecac');
30033003
});
30043004

30053005
// These might throw different error (e.g. isecobj, isecfn),
@@ -3012,11 +3012,11 @@ describe('parser', function() {
30123012

30133013
expect(function() {
30143014
scope.$eval(constructorExpr + '.join');
3015-
}).not.toThrowMinErr('$parse', 'isecaf');
3015+
}).not.toThrowMinErr('$parse', 'isecac');
30163016
expect(function() {
30173017
delete scope.foo;
30183018
scope.$eval('foo = ' + constructorExpr + '.join');
3019-
}).not.toThrowMinErr('$parse', 'isecaf');
3019+
}).not.toThrowMinErr('$parse', 'isecac');
30203020
expect(function() {
30213021
scope.$eval(constructorExpr + '.join = ""');
30223022
}).toThrow();
@@ -3039,11 +3039,11 @@ describe('parser', function() {
30393039
expect(function() {
30403040
scope.foo = thing.constructor;
30413041
scope.$eval('foo[0] = ""');
3042-
}).toThrowMinErr('$parse', 'isecaf');
3042+
}).toThrowMinErr('$parse', 'isecac');
30433043
expect(function() {
30443044
delete scope.foo;
30453045
scope.$eval('foo[0] = ""', {foo: thing.constructor});
3046-
}).toThrowMinErr('$parse', 'isecaf');
3046+
}).toThrowMinErr('$parse', 'isecac');
30473047
});
30483048

30493049
// foo.constructor is not a constructor.
@@ -3054,10 +3054,10 @@ describe('parser', function() {
30543054

30553055
expect(function() {
30563056
scope.$eval('"a".constructor.prototype.charAt = [].join');
3057-
}).toThrowMinErr('$parse', 'isecaf');
3057+
}).toThrowMinErr('$parse', 'isecac');
30583058
expect(function() {
30593059
scope.$eval('"a".constructor.prototype.charCodeAt = [].concat');
3060-
}).toThrowMinErr('$parse', 'isecaf');
3060+
}).toThrowMinErr('$parse', 'isecac');
30613061
});
30623062

30633063
it('should prevent assigning in the context of a constructor prototype', function() {
@@ -3079,35 +3079,35 @@ describe('parser', function() {
30793079
}).not.toThrow();
30803080
expect(function() {
30813081
scope.$eval(prototypeExpr + '.boin = ""');
3082-
}).toThrowMinErr('$parse', 'isecaf');
3082+
}).toThrowMinErr('$parse', 'isecac');
30833083
expect(function() {
30843084
scope.$eval(prototypeExpr + '[0] = ""');
3085-
}).toThrowMinErr('$parse', 'isecaf');
3085+
}).toThrowMinErr('$parse', 'isecac');
30863086
expect(function() {
30873087
delete scope.foo;
30883088
scope.$eval('foo = ' + constructorExpr + '; foo.prototype.boin = ""');
3089-
}).toThrowMinErr('$parse', 'isecaf');
3089+
}).toThrowMinErr('$parse', 'isecac');
30903090
expect(function() {
30913091
delete scope.foo;
30923092
scope.$eval('foo = ' + prototypeExpr + '; foo.boin = ""');
3093-
}).toThrowMinErr('$parse', 'isecaf');
3093+
}).toThrowMinErr('$parse', 'isecac');
30943094

30953095
expect(function() {
30963096
scope.foo = thing.constructor;
30973097
scope.$eval('foo.prototype[0] = ""');
3098-
}).toThrowMinErr('$parse', 'isecaf');
3098+
}).toThrowMinErr('$parse', 'isecac');
30993099
expect(function() {
31003100
delete scope.foo;
31013101
scope.$eval('foo.prototype[0] = ""', {foo: thing.constructor});
3102-
}).toThrowMinErr('$parse', 'isecaf');
3102+
}).toThrowMinErr('$parse', 'isecac');
31033103
expect(function() {
31043104
scope.foo = thing.constructor.prototype;
31053105
scope.$eval('foo[0] = ""');
3106-
}).toThrowMinErr('$parse', 'isecaf');
3106+
}).toThrowMinErr('$parse', 'isecac');
31073107
expect(function() {
31083108
delete scope.foo;
31093109
scope.$eval('foo[0] = ""', {foo: thing.constructor.prototype});
3110-
}).toThrowMinErr('$parse', 'isecaf');
3110+
}).toThrowMinErr('$parse', 'isecac');
31113111
});
31123112

31133113
// These might throw different error (e.g. isecobj, isecfn),
@@ -3121,11 +3121,11 @@ describe('parser', function() {
31213121

31223122
expect(function() {
31233123
scope.$eval(prototypeExpr + '.boin');
3124-
}).not.toThrowMinErr('$parse', 'isecaf');
3124+
}).not.toThrowMinErr('$parse', 'isecac');
31253125
expect(function() {
31263126
delete scope.foo;
31273127
scope.$eval('foo = ' + prototypeExpr + '.boin');
3128-
}).not.toThrowMinErr('$parse', 'isecaf');
3128+
}).not.toThrowMinErr('$parse', 'isecac');
31293129
expect(function() {
31303130
scope.$eval(prototypeExpr + '.boin = ""');
31313131
}).toThrow();
@@ -3144,19 +3144,19 @@ describe('parser', function() {
31443144
expect(function() {
31453145
scope.foo = thing.constructor;
31463146
scope.$eval('foo.prototype[0] = ""');
3147-
}).toThrowMinErr('$parse', 'isecaf');
3147+
}).toThrowMinErr('$parse', 'isecac');
31483148
expect(function() {
31493149
delete scope.foo;
31503150
scope.$eval('foo.prototype[0] = ""', {foo: thing.constructor});
3151-
}).toThrowMinErr('$parse', 'isecaf');
3151+
}).toThrowMinErr('$parse', 'isecac');
31523152
expect(function() {
31533153
scope.foo = thing.constructor.prototype;
31543154
scope.$eval('foo[0] = ""');
3155-
}).toThrowMinErr('$parse', 'isecaf');
3155+
}).toThrowMinErr('$parse', 'isecac');
31563156
expect(function() {
31573157
delete scope.foo;
31583158
scope.$eval('foo[0] = ""', {foo: thing.constructor.prototype});
3159-
}).toThrowMinErr('$parse', 'isecaf');
3159+
}).toThrowMinErr('$parse', 'isecac');
31603160
});
31613161

31623162
// foo.constructor.prototype is not a constructor prototype.

0 commit comments

Comments
 (0)