Skip to content

IndexOutOfRangeException during execution of compiled templates #484

Description

@abraham-fox

Describe the bug

Handlebars.net throws IndexOutOfRangeException from HandlebarsDotNet.PathStructure.PathResolver.ResolvePath() on execution of compiled templates that have loose closing blocks.

Examples of templates:
{{#if 0}}test{{/if}}{{/unless}}
{{#if 1}}{{#unless 0}}test{{/if}}{{/unless}}{{/if}}

Expected behavior:

Handlebars.net compiler should catch this type of template errors during parsing and building expression trees and throw HandlebarsCompilerException with a meaningful error message.

Test to reproduce

[Fact]publicvoidTestLooseClosingBlockExpressionException(){Assert.Throws<HandlebarsCompilerException>(()=>{Handlebars.Compile("{{#if 0}}test{{/if}}{{/unless}}")(new{});});}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions