[ 
https://issues.apache.org/jira/browse/VELOCITY-587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567736#action_12567736
 ] 

Nathan Bubna commented on VELOCITY-587:
---------------------------------------

There's plenty of inconsistencies and shortcomings in Velocity's escaping 
support.  Personally i never use or recommend the use of \ for escaping in 
either general template content nor interpolated strings (where it is most 
broken!) for that reason.  Of course, this years-long practice has 
significantly reduced my motivation to help remedy this, as it is reflexive to 
avoid the matter entirely. :(

On second thought, there is a bug here, in that neither #set( $foo = "\" ) nor 
#set( $foo = "\." ) should cause the lexical errors that they do, though that 
is somewhat different than title.  I suppose i should read more thoroughly.  Of 
course, this is Monday and i've loads of email to rush through... :-/  Sorry, 
Jon.  You've got a bug here.  I'll just change the title to fit better...

> The VTL does not have a trivial construction for strings containing a single 
> backslash (\)
> ------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-587
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-587
>             Project: Velocity
>          Issue Type: Bug
>            Reporter: Jon Seymour
>            Priority: Minor
>
> The VTL doesn't currently provide a way to express strings containing a 
> single backslash (\)
>     #set($backslash="\") 
> results in a lexical error during template parsing.
>    #set($backslash="\\")
> results in $backslash being assigned a string containing two backslashes (\\)
> It appears the only workaround available now is to construct a variable 
> containing just  a single backslash with this idiom:
>    #set($twobackslashes="\\")
>    #set($backslash=$twobackslashes.substring(0,1))
> Even if this can't be fixed in the parser, the documentation should be 
> updated to define a preferred idiom for obtaining a string containing a 
> single backslash.
> jon.
> note: this issue partially duplicates a comment by Guido Deinhammer on issue 
> #454 regarding other escaping issues. I have raised a separate issue, so that 
> this one can be addressed separately, if desired.

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to