@@ -868,7 +868,6 @@ describe('parser', function() {
868
868
} ) ;
869
869
870
870
871
-
872
871
it ( 'should understand logical operators' , function ( ) {
873
872
forEach ( [ '||' , '&&' ] , function ( operator ) {
874
873
expect ( createAst ( 'foo' + operator + 'bar' ) ) . toEqual (
@@ -918,7 +917,6 @@ describe('parser', function() {
918
917
} ) ;
919
918
920
919
921
-
922
920
it ( 'should understand ternary operators' , function ( ) {
923
921
expect ( createAst ( 'foo?bar:baz' ) ) . toEqual (
924
922
{
@@ -1083,7 +1081,6 @@ describe('parser', function() {
1083
1081
} ) ;
1084
1082
1085
1083
1086
-
1087
1084
it ( 'should give higher precedence to the logical `or` than to the conditional operator' , function ( ) {
1088
1085
expect ( createAst ( 'foo||bar?man:shell' ) ) . toEqual (
1089
1086
{
@@ -1355,6 +1352,7 @@ describe('parser', function() {
1355
1352
) ;
1356
1353
} ) ;
1357
1354
1355
+
1358
1356
it ( 'should understand ES6 object initializer' , function ( ) {
1359
1357
// Shorthand properties definitions.
1360
1358
expect ( createAst ( '{x, y, z}' ) ) . toEqual (
@@ -1447,6 +1445,7 @@ describe('parser', function() {
1447
1445
) ;
1448
1446
} ) ;
1449
1447
1448
+
1450
1449
it ( 'should understand multiple expressions' , function ( ) {
1451
1450
expect ( createAst ( 'foo = bar; man = shell' ) ) . toEqual (
1452
1451
{
@@ -1551,6 +1550,7 @@ describe('parser', function() {
1551
1550
) ;
1552
1551
} ) ;
1553
1552
1553
+
1554
1554
it ( 'should give higher precedence to assignments over filters' , function ( ) {
1555
1555
expect ( createAst ( 'foo=bar | man' ) ) . toEqual (
1556
1556
{
@@ -1577,6 +1577,7 @@ describe('parser', function() {
1577
1577
) ;
1578
1578
} ) ;
1579
1579
1580
+
1580
1581
it ( 'should accept expression as filters parameters' , function ( ) {
1581
1582
expect ( createAst ( 'foo | bar:baz=man' ) ) . toEqual (
1582
1583
{
@@ -1604,6 +1605,7 @@ describe('parser', function() {
1604
1605
) ;
1605
1606
} ) ;
1606
1607
1608
+
1607
1609
it ( 'should accept expression as computer members' , function ( ) {
1608
1610
expect ( createAst ( 'foo[a = 1]' ) ) . toEqual (
1609
1611
{
@@ -1628,6 +1630,7 @@ describe('parser', function() {
1628
1630
) ;
1629
1631
} ) ;
1630
1632
1633
+
1631
1634
it ( 'should accept expression in function arguments' , function ( ) {
1632
1635
expect ( createAst ( 'foo(a = 1)' ) ) . toEqual (
1633
1636
{
@@ -1653,6 +1656,7 @@ describe('parser', function() {
1653
1656
) ;
1654
1657
} ) ;
1655
1658
1659
+
1656
1660
it ( 'should accept expression as part of ternary operators' , function ( ) {
1657
1661
expect ( createAst ( 'foo || bar ? man = 1 : shell = 1' ) ) . toEqual (
1658
1662
{
@@ -1687,6 +1691,7 @@ describe('parser', function() {
1687
1691
) ;
1688
1692
} ) ;
1689
1693
1694
+
1690
1695
it ( 'should accept expression as part of array literals' , function ( ) {
1691
1696
expect ( createAst ( '[foo = 1]' ) ) . toEqual (
1692
1697
{
@@ -1711,6 +1716,7 @@ describe('parser', function() {
1711
1716
) ;
1712
1717
} ) ;
1713
1718
1719
+
1714
1720
it ( 'should accept expression as part of object literals' , function ( ) {
1715
1721
expect ( createAst ( '{foo: bar = 1}' ) ) . toEqual (
1716
1722
{
@@ -1741,6 +1747,7 @@ describe('parser', function() {
1741
1747
) ;
1742
1748
} ) ;
1743
1749
1750
+
1744
1751
it ( 'should be possible to use parenthesis to indicate precedence' , function ( ) {
1745
1752
expect ( createAst ( '(foo + bar).man' ) ) . toEqual (
1746
1753
{
@@ -1765,6 +1772,7 @@ describe('parser', function() {
1765
1772
) ;
1766
1773
} ) ;
1767
1774
1775
+
1768
1776
it ( 'should skip empty expressions' , function ( ) {
1769
1777
expect ( createAst ( 'foo;;;;bar' ) ) . toEqual (
1770
1778
{
@@ -1813,9 +1821,10 @@ describe('parser', function() {
1813
1821
} ] ) ) ;
1814
1822
1815
1823
forEach ( [ true , false ] , function ( cspEnabled ) {
1816
- beforeEach ( module ( [ '$parseProvider' , function ( parseProvider ) {
1817
- parseProvider . addLiteral ( 'Infinity' , Infinity ) ;
1818
- } ] ) ) ;
1824
+ beforeEach ( module ( function ( $parseProvider ) {
1825
+ $parseProvider . addLiteral ( 'Infinity' , Infinity ) ;
1826
+ csp ( ) . noUnsafeEval = cspEnabled ;
1827
+ } ) ) ;
1819
1828
1820
1829
it ( 'should allow extending literals with csp ' + cspEnabled , inject ( function ( $rootScope ) {
1821
1830
expect ( $rootScope . $eval ( "Infinity" ) ) . toEqual ( Infinity ) ;
@@ -2115,16 +2124,16 @@ describe('parser', function() {
2115
2124
expect ( scope . b ) . toEqual ( 234 ) ;
2116
2125
} ) ;
2117
2126
2118
- it ( 'should evaluate assignments in ternary operator' , function ( ) {
2119
- scope . $eval ( 'a = 1 ? 2 : 3' ) ;
2120
- expect ( scope . a ) . toBe ( 2 ) ;
2127
+ it ( 'should evaluate assignments in ternary operator' , function ( ) {
2128
+ scope . $eval ( 'a = 1 ? 2 : 3' ) ;
2129
+ expect ( scope . a ) . toBe ( 2 ) ;
2121
2130
2122
- scope . $eval ( '0 ? a = 2 : a = 3' ) ;
2123
- expect ( scope . a ) . toBe ( 3 ) ;
2131
+ scope . $eval ( '0 ? a = 2 : a = 3' ) ;
2132
+ expect ( scope . a ) . toBe ( 3 ) ;
2124
2133
2125
- scope . $eval ( '1 ? a = 2 : a = 3' ) ;
2126
- expect ( scope . a ) . toBe ( 2 ) ;
2127
- } ) ;
2134
+ scope . $eval ( '1 ? a = 2 : a = 3' ) ;
2135
+ expect ( scope . a ) . toBe ( 2 ) ;
2136
+ } ) ;
2128
2137
2129
2138
it ( 'should evaluate function call without arguments' , function ( ) {
2130
2139
scope [ 'const' ] = function ( a , b ) { return 123 ; } ;
@@ -2416,7 +2425,6 @@ describe('parser', function() {
2416
2425
} ) . toThrowMinErr (
2417
2426
'$parse' , 'isecfn' , 'Referencing Function in Angular expressions is disallowed! ' +
2418
2427
'Expression: {}.toString.constructor' ) ;
2419
-
2420
2428
} ) ;
2421
2429
2422
2430
it ( 'should not allow access to the Function prototype in the getter' , function ( ) {
@@ -2425,7 +2433,6 @@ describe('parser', function() {
2425
2433
} ) . toThrowMinErr (
2426
2434
'$parse' , 'isecfn' , 'Referencing Function in Angular expressions is disallowed! ' +
2427
2435
'Expression: toString.constructor.prototype' ) ;
2428
-
2429
2436
} ) ;
2430
2437
2431
2438
it ( 'should NOT allow access to Function constructor in getter' , function ( ) {
@@ -2434,7 +2441,6 @@ describe('parser', function() {
2434
2441
} ) . toThrowMinErr (
2435
2442
'$parse' , 'isecfn' , 'Referencing Function in Angular expressions is disallowed! ' +
2436
2443
'Expression: {}.toString.constructor("alert(1)")' ) ;
2437
-
2438
2444
} ) ;
2439
2445
2440
2446
it ( 'should NOT allow access to Function constructor in setter' , function ( ) {
@@ -2935,14 +2941,14 @@ describe('parser', function() {
2935
2941
} ) ;
2936
2942
} ) ;
2937
2943
2938
- it ( 'should prevent the exploit' , function ( ) {
2939
- expect ( function ( ) {
2940
- scope . $eval ( '(1)[{0: "__proto__", 1: "__proto__", 2: "__proto__", 3: "safe", length: 4, toString: [].pop}].foo = 1' ) ;
2941
- } ) . toThrow ( ) ;
2942
- if ( ! msie || msie > 10 ) {
2943
- expect ( ( 1 ) [ '__proto__' ] . foo ) . toBeUndefined ( ) ;
2944
- }
2945
- } ) ;
2944
+ it ( 'should prevent the exploit' , function ( ) {
2945
+ expect ( function ( ) {
2946
+ scope . $eval ( '(1)[{0: "__proto__", 1: "__proto__", 2: "__proto__", 3: "safe", length: 4, toString: [].pop}].foo = 1' ) ;
2947
+ } ) . toThrow ( ) ;
2948
+ if ( ! msie || msie > 10 ) {
2949
+ expect ( ( 1 ) [ '__proto__' ] . foo ) . toBeUndefined ( ) ;
2950
+ }
2951
+ } ) ;
2946
2952
2947
2953
it ( 'should prevent the exploit' , function ( ) {
2948
2954
expect ( function ( ) {
@@ -3324,7 +3330,6 @@ describe('parser', function() {
3324
3330
expect ( $rootScope . $$watchers . length ) . toBe ( 1 ) ;
3325
3331
expect ( log ) . toEqual ( [ ] ) ;
3326
3332
} ) ) ;
3327
-
3328
3333
} ) ;
3329
3334
} ) ;
3330
3335
0 commit comments