Skip to content

Stack blown when nested "@partial-block"-using partial not given a partial block. #1185

@damncabbage

Description

@damncabbage

I just hit this in the wild with someone accidentally calling a @partial-block-using partial without giving it said partial block.

Minimal example:

var Handlebars = require('handlebars');
Handlebars.registerPartial('outer', '<p>{{> @partial-block }}</p>');
Handlebars.registerPartial('inner', '<span>{{> @partial-block }}</span>');

// Calls "inner" without giving it a partial block.
Handlebars.compile("<div>{{#>outer}} {{>inner}} {{/outer}}</div>")(); 

Produces:

RangeError: Maximum call stack size exceeded
    at Object.eval (eval at createFunctionContext (…/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:1:10)
    at main (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
    at ret (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
    at ret (…/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21)
    at Object.invokePartial (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
    at Object.invokePartialWrapper [as invokePartial] (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
    at eval (eval at createFunctionContext (…/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:28)
    at prog (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:219:12)
    at Object.invokePartial (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:268:12)
    at Object.invokePartialWrapper [as invokePartial] (…/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)

As far as I can tell: the inner partial, when not giving a partial-block of its own, will refer to the @partial-block given to the outer partial.

Tested with Handlebars 4.0.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions