velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Byron Foster (JIRA)" <>
Subject [jira] Commented: (VELOCITY-618) Strict property and method references
Date Mon, 06 Oct 2008 23:26:44 GMT


Byron Foster commented on VELOCITY-618:

The problem that comes up in strict mode is if you have a situation in a template where something
looks like a variable such as 'abc$xyz'.  Since this wouldn't be a defined variable, an exception
would be thrown.  I think the developer needs an easy way to escape these character sequences
like 'abc\$xyz, and I think it would be a shame to burden strict mode with something like
'abc${DOL}xyz' :)

While this is a change in behavior, I don't think it is very dramatic, and it does act just
like non strict mode for defined variables.  in strict mode:

$abc = <exception>
\$abc = $abc
\\$abc = <exception>
\\\$abc = \$abc

I bet money that when Velocity throws an exception on an unintended variable pattern, the
first thing a developer will try is to throw a back slash in front of it.  I would be surprised
if someone cried fowl over it not being consistent with their understanding of the Velocity
escaping rules.  I have used Velocity on and off for years, and when this issue came up I
still had to go to the docs to understand what the behavior is.. and still :)   Anyway.. that's
my case, let me know if you'd like to see a change to this.

> Strict property and method references
> -------------------------------------
>                 Key: VELOCITY-618
>                 URL:
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Byron Foster
>             Fix For: 1.5.1, 1.6
>         Attachments: MacroAndVarEscape.patch, strictPropertyAndVariable_3.patch
> The given patch against trunk adds a new option 'runtime.references.strict'.  When set
to true, invalid property references will throw a InvalidMethodException.  For example $
will throw an exception if the object contained in $foo has no such property as bar.  Any
kind of reference to bar will cause an exception including:
> #if(
> #set($ = "junk")
> #set($foo.getBar())
> etc...

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message