File tree 3 files changed +26
-11
lines changed
3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,8 @@ main(arguments) {
225
225
"1|nonexistent" ,
226
226
"publicField" ,
227
227
"_privateField" ,
228
- "'World'|hello"
228
+ "'World'|hello" ,
229
+ "1;'World'|hello" ,
230
+ "'World'|hello;1"
229
231
]);
230
232
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ library angular.core.parser.dynamic_parser_impl;
2
2
3
3
import 'package:angular/core/parser/parser.dart' show ParserBackend;
4
4
import 'package:angular/core/parser/lexer.dart' ;
5
+ import 'package:angular/core/parser/syntax.dart' ;
5
6
6
7
class DynamicParserImpl {
7
8
static Token EOF = new Token (- 1 , null );
@@ -18,14 +19,23 @@ class DynamicParserImpl {
18
19
}
19
20
20
21
parseChain () {
21
- while (optional (';' ));
22
+ bool isChain = false ;
23
+ while (optional (';' )) {
24
+ isChain = true ;
25
+ }
22
26
List expressions = [];
23
27
while (index < tokens.length) {
24
28
if (peek.text == ')' || peek.text == '}' || peek.text == ']' ) {
25
29
error ('Unconsumed token ${peek .text }' );
26
30
}
27
- expressions.add (parseFilter ());
28
- while (optional (';' ));
31
+ var expr = parseFilter ();
32
+ expressions.add (expr);
33
+ while (optional (';' )) {
34
+ isChain = true ;
35
+ }
36
+ if (isChain && expr is Filter ) {
37
+ error ('cannot have a filter in a chain' );
38
+ }
29
39
}
30
40
return (expressions.length == 1 )
31
41
? expressions.first
@@ -203,7 +213,7 @@ class DynamicParserImpl {
203
213
204
214
parsePrimary () {
205
215
if (optional ('(' )) {
206
- var result = parseFilter ();
216
+ var result = parseExpression ();
207
217
expect (')' );
208
218
return result;
209
219
} else if (optional ('null' ) || optional ('undefined' )) {
Original file line number Diff line number Diff line change @@ -897,12 +897,6 @@ main() {
897
897
expect (eval ("1|increment:2" , filters)).toEqual (3 );
898
898
});
899
899
900
- it ('should evaluate grouped filters' , () {
901
- scope.name = 'MISKO' ;
902
- expect (scope.$eval ('n = (name|lowercase)' )).toEqual ('misko' );
903
- expect (scope.$eval ('n' )).toEqual ('misko' );
904
- });
905
-
906
900
it ('should parse filters' , () {
907
901
expect (() {
908
902
scope.$eval ("1|nonexistent" );
@@ -930,6 +924,15 @@ main() {
930
924
931
925
expect (expression.eval ({}, newFilters)).toEqual ('Hello, World!' );
932
926
}));
927
+
928
+ it ('should not allow filters in a chain' , () {
929
+ expect (() {
930
+ parser ("1;'World'|hello" );
931
+ }).toThrow ('cannot have a filter in a chain the end of the expression [1;\' World\' |hello]' );
932
+ expect (() {
933
+ parser ("'World'|hello;1" );
934
+ }).toThrow ('cannot have a filter in a chain at column 15 in [\' World\' |hello;1]' );
935
+ });
933
936
});
934
937
});
935
938
}
You can’t perform that action at this time.
0 commit comments