[ 
https://issues.apache.org/jira/browse/VELOCITY-961?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Éamonn McManus updated VELOCITY-961:
------------------------------------
    Description: 
The following template parses correctly with Velocity 1.7:
{noformat}
$child.typeName()#if($child.isRepeated())[]#end{noformat}
But with 2.3 it gets an exception:
{noformat}
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){noformat}
I think the template is correct and should work with both versions.

I was able to work around the bug like this:
{noformat}
$set ($squares = '[]')
$child.typeName()#if($child.isRepeated())$squares#end{noformat}

  was:
The following template parses correctly with Velocity 1.7:
{noformat}
$child.typeName()#if($child.isRepeated())[]#end{noformat}
But with 2.3 it gets an exception:
{noformat}
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){noformat}
I think the template is correct and should work with both versions.


> Parsing regression in Velocity 2.3
> ----------------------------------
>
>                 Key: VELOCITY-961
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-961
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 2.3
>            Reporter: Éamonn McManus
>            Priority: Minor
>
> The following template parses correctly with Velocity 1.7:
> {noformat}
> $child.typeName()#if($child.isRepeated())[]#end{noformat}
> But with 2.3 it gets an exception:
> {noformat}
> 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){noformat}
> I think the template is correct and should work with both versions.
> I was able to work around the bug like this:
> {noformat}
> $set ($squares = '[]')
> $child.typeName()#if($child.isRepeated())$squares#end{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to