@@ -591,57 +591,6 @@ describe('parser', function() {
591591 } ) ;
592592
593593 describe ( 'sandboxing' , function ( ) {
594- describe ( 'private members' , function ( ) {
595- it ( 'should NOT allow access to private members' , function ( ) {
596- forEach ( [ '_name' , 'name_' , '_' , '_name_' ] , function ( name ) {
597- function _testExpression ( expression ) {
598- scope . a = { b : name } ;
599- scope [ name ] = { a : scope . a } ;
600- scope . piece_1 = "XX" + name . charAt ( 0 ) + "XX" ;
601- scope . piece_2 = "XX" + name . substr ( 1 ) + "XX" ;
602- expect ( function ( ) {
603- scope . $eval ( expression ) ;
604- } ) . toThrowMinErr (
605- '$parse' , 'isecprv' , 'Referencing private fields in Angular expressions is disallowed! ' +
606- 'Expression: ' + expression ) ;
607- }
608-
609- function testExpression ( expression ) {
610- if ( expression . indexOf ( '"NAME"' ) != - 1 ) {
611- var concatExpr = 'piece_1.substr(2, 1) + piece_2.substr(2, LEN)' . replace ( 'LEN' , name . length - 1 ) ;
612- _testExpression ( expression . replace ( / " N A M E " / g, concatExpr ) ) ;
613- _testExpression ( expression . replace ( / " N A M E " / g, '(' + concatExpr + ')' ) ) ;
614- }
615- _testExpression ( expression . replace ( / N A M E / g, name ) ) ;
616- }
617-
618- // Not all of these are exploitable. The tests ensure that the contract is honored
619- // without caring about the implementation or exploitability.
620- testExpression ( 'NAME' ) ; testExpression ( 'NAME = 1' ) ;
621- testExpression ( '(NAME)' ) ; testExpression ( '(NAME) = 1' ) ;
622- testExpression ( 'a.NAME' ) ; testExpression ( 'a.NAME = 1' ) ;
623- testExpression ( 'NAME.b' ) ; testExpression ( 'NAME.b = 1' ) ;
624- testExpression ( 'a.NAME.b' ) ; testExpression ( 'a.NAME.b = 1' ) ;
625- testExpression ( 'NAME()' ) ; testExpression ( 'NAME() = 1' ) ;
626- testExpression ( '(NAME)()' ) ; testExpression ( '(NAME = 1)()' ) ;
627- testExpression ( '(NAME).foo()' ) ; testExpression ( '(NAME = 1).foo()' ) ;
628- testExpression ( 'a.NAME()' ) ; testExpression ( 'a.NAME() = 1' ) ;
629- testExpression ( 'a.NAME.foo()' ) ; testExpression ( 'a.NAME.foo()' ) ;
630- testExpression ( 'foo(NAME)' ) ; testExpression ( 'foo(NAME = 1)' ) ;
631- testExpression ( 'foo(a.NAME)' ) ; testExpression ( 'foo(a.NAME = 1)' ) ;
632- testExpression ( 'foo(1, a.NAME)' ) ; testExpression ( 'foo(1, a.NAME = 1)' ) ;
633- testExpression ( 'foo(a["NAME"])' ) ; testExpression ( 'foo(a["NAME"] = 1)' ) ;
634- testExpression ( 'foo(1, a["NAME"])' ) ; testExpression ( 'foo(1, a["NAME"] = 1)' ) ;
635- testExpression ( 'foo(b = a["NAME"])' ) ; testExpression ( 'foo(b = (a["NAME"] = 1))' ) ;
636- testExpression ( 'a["NAME"]' ) ; testExpression ( 'a["NAME"] = 1' ) ;
637- testExpression ( 'a["NAME"]()' ) ;
638- testExpression ( 'a["NAME"].foo()' ) ;
639- testExpression ( 'a.b["NAME"]' ) ; testExpression ( 'a.b["NAME"] = 1' ) ;
640- testExpression ( 'a["b"]["NAME"]' ) ; testExpression ( 'a["b"]["NAME"] = 1' ) ;
641- } ) ;
642- } ) ;
643- } ) ;
644-
645594 describe ( 'Function constructor' , function ( ) {
646595 it ( 'should NOT allow access to Function constructor in getter' , function ( ) {
647596 expect ( function ( ) {
@@ -702,29 +651,17 @@ describe('parser', function() {
702651 expect ( function ( ) {
703652 scope . $eval ( '{}.toString["constructor"]["constructor"] = 1' ) ;
704653 } ) . toThrowMinErr (
705- '$parse' , 'isecfld ' , 'Referencing "constructor" field in Angular expressions is disallowed! ' +
654+ '$parse' , 'isecfn ' , 'Referencing Function in Angular expressions is disallowed! ' +
706655 'Expression: {}.toString["constructor"]["constructor"] = 1' ) ;
707656
708657
709658 scope . key1 = "const" ;
710659 scope . key2 = "ructor" ;
711- expect ( function ( ) {
712- scope . $eval ( '{}.toString[key1 + key2].foo' ) ;
713- } ) . toThrowMinErr (
714- '$parse' , 'isecfn' , 'Referencing Function in Angular expressions is disallowed! ' +
715- 'Expression: {}.toString[key1 + key2].foo' ) ;
716-
717- expect ( function ( ) {
718- scope . $eval ( '{}.toString[key1 + key2] = 1' ) ;
719- } ) . toThrowMinErr (
720- '$parse' , 'isecfld' , 'Referencing "constructor" field in Angular expressions is disallowed! ' +
721- 'Expression: {}.toString[key1 + key2] = 1' ) ;
722-
723660 expect ( function ( ) {
724661 scope . $eval ( '{}.toString[key1 + key2].foo = 1' ) ;
725662 } ) . toThrowMinErr (
726663 '$parse' , 'isecfn' , 'Referencing Function in Angular expressions is disallowed! ' +
727- 'Expression: {}.toString[key1 + key2].foo = 1' ) ;
664+ 'Expression: {}.toString[key1 + key2].foo = 1' ) ;
728665
729666 expect ( function ( ) {
730667 scope . $eval ( '{}.toString["constructor"]["a"] = 1' ) ;
0 commit comments