From aade2612b1f9ba2c673771c882385ae639c977dd Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sat, 27 Feb 2021 09:36:00 +0100 Subject: [engine] Fix VELOCITY-927 --- velocity-engine-core/src/main/parser/Parser.jjt | 2 +- .../velocity/test/issues/Velocity927TestCase.java | 39 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity927TestCase.java (limited to 'velocity-engine-core/src') diff --git a/velocity-engine-core/src/main/parser/Parser.jjt b/velocity-engine-core/src/main/parser/Parser.jjt index df5748d7..593d044b 100644 --- a/velocity-engine-core/src/main/parser/Parser.jjt +++ b/velocity-engine-core/src/main/parser/Parser.jjt @@ -2073,7 +2073,7 @@ void Map() : {} { ( - LOOKAHEAD(2) Parameter() Parameter() ( Parameter() Parameter() )* + LOOKAHEAD(( | )* Parameter() ) ( Parameter() Parameter() ( Parameter() Parameter() )* ) | ( | )* ) diff --git a/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity927TestCase.java b/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity927TestCase.java new file mode 100755 index 00000000..218ed7f2 --- /dev/null +++ b/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity927TestCase.java @@ -0,0 +1,39 @@ +package org.apache.velocity.test.issues; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.velocity.test.BaseTestCase; + +/** + * This class tests bugfix for http://stackoverflow.com/questions/32805217/bug-or-hidden-feature-in-apache-velocity + */ +public class Velocity927TestCase extends BaseTestCase +{ + public Velocity927TestCase(String name) + { + super(name); + } + + public void testIt() + { + assertEvalEquals("", "#set($map = {\n })"); + } + +} -- cgit v1.2.3