@@ -167,6 +167,7 @@ describe('security issues', function() {
167
167
TestClass . prototype . aMethod = function ( ) {
168
168
return 'returnValue' ;
169
169
} ;
170
+ TestClass . prototype . nested = new TestClass ( ) ;
170
171
171
172
beforeEach ( function ( ) {
172
173
handlebarsEnv . resetLoggedPropertyAccesses ( ) ;
@@ -177,17 +178,25 @@ describe('security issues', function() {
177
178
} ) ;
178
179
179
180
describe ( 'control access to prototype methods via "allowedProtoMethods"' , function ( ) {
180
- checkProtoMethodAccess ( { } ) ;
181
+ checkProtoMethodAccess ( '{{aMethod}}' , { } ) ;
181
182
182
183
describe ( 'in compat mode' , function ( ) {
183
- checkProtoMethodAccess ( { compat : true } ) ;
184
+ checkProtoMethodAccess ( '{{aMethod}}' , { compat : true } ) ;
184
185
} ) ;
185
186
186
- function checkProtoMethodAccess ( compileOptions ) {
187
+ describe ( 'GH-1858: for nested object' , function ( ) {
188
+ checkProtoMethodAccess ( '{{nested.aMethod}}' , { } ) ;
189
+
190
+ describe ( 'in compat mode' , function ( ) {
191
+ checkProtoMethodAccess ( '{{nested.aMethod}}' , { compat : true } ) ;
192
+ } ) ;
193
+ } ) ;
194
+
195
+ function checkProtoMethodAccess ( template , compileOptions ) {
187
196
it ( 'should be prohibited by default and log a warning' , function ( ) {
188
197
var spy = sinon . spy ( console , 'error' ) ;
189
198
190
- expectTemplate ( '{{aMethod}}' )
199
+ expectTemplate ( template )
191
200
. withInput ( new TestClass ( ) )
192
201
. withCompileOptions ( compileOptions )
193
202
. toCompileTo ( '' ) ;
@@ -199,12 +208,12 @@ describe('security issues', function() {
199
208
it ( 'should only log the warning once' , function ( ) {
200
209
var spy = sinon . spy ( console , 'error' ) ;
201
210
202
- expectTemplate ( '{{aMethod}}' )
211
+ expectTemplate ( template )
203
212
. withInput ( new TestClass ( ) )
204
213
. withCompileOptions ( compileOptions )
205
214
. toCompileTo ( '' ) ;
206
215
207
- expectTemplate ( '{{aMethod}}' )
216
+ expectTemplate ( template )
208
217
. withInput ( new TestClass ( ) )
209
218
. withCompileOptions ( compileOptions )
210
219
. toCompileTo ( '' ) ;
@@ -216,7 +225,7 @@ describe('security issues', function() {
216
225
it ( 'can be allowed, which disables the warning' , function ( ) {
217
226
var spy = sinon . spy ( console , 'error' ) ;
218
227
219
- expectTemplate ( '{{aMethod}}' )
228
+ expectTemplate ( template )
220
229
. withInput ( new TestClass ( ) )
221
230
. withCompileOptions ( compileOptions )
222
231
. withRuntimeOptions ( {
@@ -232,7 +241,7 @@ describe('security issues', function() {
232
241
it ( 'can be turned on by default, which disables the warning' , function ( ) {
233
242
var spy = sinon . spy ( console , 'error' ) ;
234
243
235
- expectTemplate ( '{{aMethod}}' )
244
+ expectTemplate ( template )
236
245
. withInput ( new TestClass ( ) )
237
246
. withCompileOptions ( compileOptions )
238
247
. withRuntimeOptions ( {
@@ -246,7 +255,7 @@ describe('security issues', function() {
246
255
it ( 'can be turned off by default, which disables the warning' , function ( ) {
247
256
var spy = sinon . spy ( console , 'error' ) ;
248
257
249
- expectTemplate ( '{{aMethod}}' )
258
+ expectTemplate ( template )
250
259
. withInput ( new TestClass ( ) )
251
260
. withCompileOptions ( compileOptions )
252
261
. withRuntimeOptions ( {
@@ -258,7 +267,7 @@ describe('security issues', function() {
258
267
} ) ;
259
268
260
269
it ( 'can be turned off, if turned on by default' , function ( ) {
261
- expectTemplate ( '{{aMethod}}' )
270
+ expectTemplate ( template )
262
271
. withInput ( new TestClass ( ) )
263
272
. withCompileOptions ( compileOptions )
264
273
. withRuntimeOptions ( {
@@ -292,21 +301,33 @@ describe('security issues', function() {
292
301
} ) ;
293
302
294
303
describe ( 'control access to prototype non-methods via "allowedProtoProperties" and "allowProtoPropertiesByDefault' , function ( ) {
295
- checkProtoPropertyAccess ( { } ) ;
304
+ checkProtoPropertyAccess ( '{{aProperty}}' , { } ) ;
296
305
297
306
describe ( 'in compat-mode' , function ( ) {
298
- checkProtoPropertyAccess ( { compat : true } ) ;
307
+ checkProtoPropertyAccess ( '{{aProperty}}' , { compat : true } ) ;
299
308
} ) ;
300
309
301
310
describe ( 'in strict-mode' , function ( ) {
302
- checkProtoPropertyAccess ( { strict : true } ) ;
311
+ checkProtoPropertyAccess ( '{{aProperty}}' , { strict : true } ) ;
303
312
} ) ;
304
313
305
- function checkProtoPropertyAccess ( compileOptions ) {
314
+ describe ( 'GH-1858: for nested object' , function ( ) {
315
+ checkProtoPropertyAccess ( '{{nested.aProperty}}' , { } ) ;
316
+
317
+ describe ( 'in compat-mode' , function ( ) {
318
+ checkProtoPropertyAccess ( '{{nested.aProperty}}' , { compat : true } ) ;
319
+ } ) ;
320
+
321
+ describe ( 'in strict-mode' , function ( ) {
322
+ checkProtoPropertyAccess ( '{{nested.aProperty}}' , { strict : true } ) ;
323
+ } ) ;
324
+ } ) ;
325
+
326
+ function checkProtoPropertyAccess ( template , compileOptions ) {
306
327
it ( 'should be prohibited by default and log a warning' , function ( ) {
307
328
var spy = sinon . spy ( console , 'error' ) ;
308
329
309
- expectTemplate ( '{{aProperty}}' )
330
+ expectTemplate ( template )
310
331
. withInput ( new TestClass ( ) )
311
332
. withCompileOptions ( compileOptions )
312
333
. toCompileTo ( '' ) ;
@@ -318,7 +339,7 @@ describe('security issues', function() {
318
339
it ( 'can be explicitly prohibited by default, which disables the warning' , function ( ) {
319
340
var spy = sinon . spy ( console , 'error' ) ;
320
341
321
- expectTemplate ( '{{aProperty}}' )
342
+ expectTemplate ( template )
322
343
. withInput ( new TestClass ( ) )
323
344
. withCompileOptions ( compileOptions )
324
345
. withRuntimeOptions ( {
@@ -332,7 +353,7 @@ describe('security issues', function() {
332
353
it ( 'can be turned on, which disables the warning' , function ( ) {
333
354
var spy = sinon . spy ( console , 'error' ) ;
334
355
335
- expectTemplate ( '{{aProperty}}' )
356
+ expectTemplate ( template )
336
357
. withInput ( new TestClass ( ) )
337
358
. withCompileOptions ( compileOptions )
338
359
. withRuntimeOptions ( {
@@ -348,7 +369,7 @@ describe('security issues', function() {
348
369
it ( 'can be turned on by default, which disables the warning' , function ( ) {
349
370
var spy = sinon . spy ( console , 'error' ) ;
350
371
351
- expectTemplate ( '{{aProperty}}' )
372
+ expectTemplate ( template )
352
373
. withInput ( new TestClass ( ) )
353
374
. withCompileOptions ( compileOptions )
354
375
. withRuntimeOptions ( {
@@ -360,7 +381,7 @@ describe('security issues', function() {
360
381
} ) ;
361
382
362
383
it ( 'can be turned off, if turned on by default' , function ( ) {
363
- expectTemplate ( '{{aProperty}}' )
384
+ expectTemplate ( template )
364
385
. withInput ( new TestClass ( ) )
365
386
. withCompileOptions ( compileOptions )
366
387
. withRuntimeOptions ( {
0 commit comments