@@ -527,7 +527,24 @@ QUnit.module('prototype pollution protection', {
527527 assert . strictEqual ( errors . log . called , false , 'should not log for safe paths' ) ;
528528 } ) ;
529529
530- test ( 'compileGetter logs error and returns undefined for __proto__ path fragment (T1330839)' , function ( assert ) {
530+ test ( 'compileSetter blocks unsafe fragment written in bracket notation (T1330839)' , function ( assert ) {
531+ const obj = { } ;
532+ SETTER ( 'a[constructor][prototype].pp_dx' ) ( obj , 'yes' , { functionsAsIs : true } ) ;
533+
534+ assert . strictEqual ( errors . log . calledWith ( 'E0123' , 'constructor' ) , true , 'should log E0123 for constructor in bracket notation' ) ;
535+ assert . strictEqual ( ( { } ) . pp_dx , undefined , 'Object.prototype must not be polluted' ) ;
536+ } ) ;
537+
538+ test ( 'compileSetter blocks unsafe fragment in non-first position (T1330839)' , function ( assert ) {
539+ const obj = { a : { b : { } } } ;
540+ SETTER ( 'a.b.__proto__' ) ( obj , { pp_dx : 'yes' } , { functionsAsIs : true } ) ;
541+
542+ assert . strictEqual ( errors . log . calledWith ( 'E0123' , '__proto__' ) , true , 'should log E0123 for __proto__ in non-first position' ) ;
543+ assert . strictEqual ( obj . a . b . pp_dx , undefined , 'nested object must not inherit a polluted property' ) ;
544+ assert . strictEqual ( ( { } ) . pp_dx , undefined , 'Object.prototype must not be polluted' ) ;
545+ } ) ;
546+
547+ test ( 'compileGetter logs error and returns undefined for __proto__ path fragent (T1330839)' , function ( assert ) {
531548 const result = GETTER ( '__proto__.pp_dx' ) ( { } ) ;
532549
533550 assert . strictEqual ( errors . log . calledWith ( 'E0123' , '__proto__' ) , true , 'should log E0123 for __proto__' ) ;
0 commit comments