Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-961

Parsing regression in Velocity 2.3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.3
    • None
    • Engine
    • None

    Description

      The following template parses correctly with Velocity 1.7:

      $child.typeName()#if($child.isRepeated())[]#end

      But with 2.3 it gets an exception:

      org.apache.velocity.runtime.parser.TemplateParseException: Encountered "[" at velocityParsingBug[line 1, column 42]
      Was expecting one of:
          "\u001c" ...
          "\u001c" ...
          "||" ...
          "|" ...
          "(" ...
          ")" ...
          <ESCAPE_DIRECTIVE> ...
          "]]#" ...
          <WHITESPACE> ...
          <NEWLINE> ...
          <SUFFIX> ...
          <STRING_LITERAL> ...
          <INTEGER_LITERAL> ...
          <FLOATING_POINT_LITERAL> ...
          <DOT> ...
          "{" ...
          "}" ...
          "\\\\" ...
          "\\" ...
          <TEXT> ...
          <INLINE_TEXT> ...
          <EMPTY_INDEX> ...
          "{" ...
          "\u001c" ...
          <WHITESPACE> ...
          <NEWLINE> ...        at org.apache.velocity.runtime.parser.StandardParser.parse(StandardParser.java:198)
              at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1341)

      I think the template is correct and should work with both versions.

      I was able to work around the bug like this:

      $set ($squares = '[]')
      $child.typeName()#if($child.isRepeated())$squares#end

      Attachments

        Activity

          People

            Unassigned Unassigned
            eamonnmcmanus Éamonn McManus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: