Skip to content

TemplateParser.ParseTemplate() crashes if the template contains a reference to a variable with "special" characters in name #53

Description

@jjanuszkiewicz

A call to TemplateParser.ParseTemplate(foo) throws an exception on some valid input such as #{foo!}:

Parsing failure: unexpected '#'; expected end of input (Line 1, Column 1); recently consumed: 
at Sprache.ParserExtensions.Parse[T](Parser`1 parser, String input)
at Octostache.Templates.TemplateParser.ParseTemplate(String template)
at IHS.Castle.Tools.OctopusUtilities.WebApi.Program.Main(String[] args) in S:\Connect.BuildTools.TestAndSources\src\IHS.Castle.Tools.OctopusUtilities.WebApi\Program.cs:line 14

Octopus Deploy allows to create variables with all kinds of characters in the name, even crazy ones like !@#$%^&*()_+-={}[]:";'<>?,./ (yes, I was able to create a variable called just that for a test), which while not the greatest practice, should be supported by this library. My team had one legitimate case where one of those characters was used, but this crashed TemplateParser.

Looking at the code of TemplateParser, it only allows the following non-alphanumerical, non-whitespace characters: _-:/~().

I could create a PR to change this, but I can't find any documentation on what characters are actually supported by Octopus Deploy in variable names.

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