Author: cbrisson
Date: Mon May 9 13:48:23 2016
New Revision: 1742952
URL: http://svn.apache.org/viewvc?rev=1742952&view=rev
Log:
disallow '-' in symbol names
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseExceptionTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/test.cmp
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/interpolation.vm
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/test.vm
Modified: velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt?rev=1742952&r1=1742951&r2=1742952&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
(original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt Mon
May 9 13:48:23 2016
@@ -685,7 +685,7 @@ TOKEN:
* DEFAULT lexical state the following VTL fails "$a#set($b = 1)"
* because the Reference token uses LOOKAHEAD(2) combined with the
* fact that we explicity set the lex state to REFERENCE with the $
- * token, which means we would never evaulate this token during the
+ * token, which means we would never evaluate this token during the
* look ahead. This general issue is disscussed here:
*
* http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-ie.htm#tth_sEc3.12
@@ -1129,7 +1129,7 @@ TOKEN:
<PRE_DIRECTIVE,DIRECTIVE>
TOKEN:
{
- <#LETTER: [ "a"-"z", "A" - "Z" ] >
+ <#LETTER: [ "a"-"z", "A"-"Z" ] >
| <#DIRECTIVE_CHAR: [ "a"-"z", "A"-"Z", "0"-"9", "_" ] >
| <WORD: ( <LETTER> | ["_"] | ["@"]) (<DIRECTIVE_CHAR>)* >
| <BRACKETED_WORD: "{" ( <LETTER> | ["_"] | ["@"]) (<DIRECTIVE_CHAR>)* "}" >
@@ -1164,7 +1164,7 @@ TOKEN :
{
<#ALPHA_CHAR: ["a"-"z", "A"-"Z"] >
| <#ALPHANUM_CHAR: [ "a"-"z", "A"-"Z", "0"-"9" ] >
-| <#IDENTIFIER_CHAR: [ "a"-"z", "A"-"Z", "0"-"9", "-", "_" ] >
+| <#IDENTIFIER_CHAR: [ "a"-"z", "A"-"Z", "0"-"9", "_" ] >
| <IDENTIFIER: ( <ALPHA_CHAR> | ["_"]) (<IDENTIFIER_CHAR>)* >
| <DOT: "." <ALPHA_CHAR>>
{
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseExceptionTestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseExceptionTestCase.java?rev=1742952&r1=1742951&r2=1742952&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseExceptionTestCase.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseExceptionTestCase.java
Mon May 9 13:48:23 2016
@@ -166,5 +166,13 @@ public class ParseExceptionTestCase exte
assertEvalEquals("test1", "#macro(foo $a)$a#end#foo('test1' 'test2')");
}
-
+ /**
+ * Minus is not any more allowed inside a symbol (reference, property or
method).
+ * @throws Exception
+ */
+ public void testParseExceptionMinusSignDissalowed()
+ throws Exception
+ {
+ assertEvalExceptionAt("${foo-bar}", 1, 6);
+ }
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/test.cmp
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/test.cmp?rev=1742952&r1=1742951&r2=1742952&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/test.cmp
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/test.cmp
Mon May 9 13:48:23 2016
@@ -33,9 +33,9 @@ $foo/ => bar/
$foo" => bar"
$foo\ => bar\
$foo< => bar<
-\$foo- => $foo-
+$foo- => bar-
\$fooo+ => $fooo+
-\$foo-x => $foo-x
+$foo-x => bar-x
$foo$ => bar$
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/interpolation.vm
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/interpolation.vm?rev=1742952&r1=1742951&r2=1742952&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/interpolation.vm
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/interpolation.vm
Mon May 9 13:48:23 2016
@@ -17,12 +17,12 @@ $provider.concat("it will cost you $10.0
#set($image = "dog")
$provider.concat("${image}.jpg", "")
-#set($foo-bar = "foobar")
-$provider.concat("${foo-bar}.jpg", "")
-
#set($foo_bar = "foobar")
$provider.concat("${foo_bar}.jpg", "")
+#set($foo__bar = "foobar")
+$provider.concat("${foo__bar}.jpg", "")
+
#set($one = 1)
#set($two = 2)
#set($three = 3)
Modified:
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/test.vm
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/test.vm?rev=1742952&r1=1742951&r2=1742952&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/test.vm
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/test.vm
Mon May 9 13:48:23 2016
@@ -70,8 +70,8 @@ This is the $foo way.
-#set($iam-cool = "jon")
-$iam-cool
+#set($iam_cool = "jon")
+$iam_cool
$!nada nothing here
function preload(imgObj,imgSrc)