You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Stefan Bodewig <bo...@apache.org> on 2010/08/02 06:18:00 UTC

Potential Regression? Escaped Quotes in String Literals

Hi all,

there is a build failure showing up in some Gump builds that seems to
indicate a backwards incompatible change inside Velocity - which may or
may not be intentional.

One example of the failure can be seen in the Cargo build
<http://vmgump.apache.org/gump/public/cargo/cargo/gump_work/build_cargo_cargo.html>.
I'll be happy to explain what Gump does, but the failure itself can be
understood without that background.

The doxia-site-renderer Maven module contains a Velocity template which
itself contains a line

        #set ( $documentHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" )

probably with the expectaation that \" would escape the quote.  This
seems to work with the version referenced by the module: 1.5.

If you try to parse the same template with the trunk of Velocity engine
you get

[ERROR] org.apache.velocity.exception.ParseErrorException: Encountered "1.0" at org/apache/maven/doxia/siterenderer/resources/default-site.vm[line 308, column 51]
Was expecting one of:
    <RPAREN> ...
    <WHITESPACE> ...

which looks as if the " before 1.0 was terminating the string literal.

I can't find any hint in Velocity's documentation that would say you can
escape quotes in string literals, but if it worked in older versions you
are setting some sort of expectation 8-)

Is this a regression that can/will be fixed or is this something the
downstream users like doxia would need to adapt to?

Stefan

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


Re: Potential Regression? Escaped Quotes in String Literals

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-08-07, Nathan Bubna wrote:

> On Mon, Aug 2, 2010 at 8:35 PM, Stefan Bodewig <bo...@apache.org> wrote:
>> On 2010-08-02, <ap...@recks.org> wrote:

>>> To my knowledge escaping of quotes was never supported by Velocity.

>> My guess is it works with Velocity 1.5 or otherwise the doxia folks
>> wouldn't be using it that way.  At least the parser doesn't choke on the
>> template in question.

> I'm 99.2% sure this never worked.

That's a pretty high confidence 8-)

>>> So in the doxia case either use a single quote for the XML attributes,
>>> or double-up the quotes, or use the poor-mans-escaping (TM):
>>>   #set( $Q = '"' )

>> I'll take this advice to the doxia people and see whether they want to
>> adapt.  "It works for 1.5 and we are not going to upgrade anyway" may be
>> an alternative answer.

> Only if by "works" you mean "fails with insufficient notice".  I
> recommend Velocity 1.7 and doubling up the quotes.

I had already opened <http://jira.codehaus.org/browse/DOXIA-400> and
have now updated it with your advice.  Since I'm really not more than an
observer in this case, that's all I can do.

Thanks again

       Stefan

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


Re: Potential Regression? Escaped Quotes in String Literals

Posted by Nathan Bubna <nb...@gmail.com>.
On Mon, Aug 2, 2010 at 8:35 PM, Stefan Bodewig <bo...@apache.org> wrote:
> On 2010-08-02, <ap...@recks.org> wrote:
>
>> even though I would love to have the established character escaping
>> with a backslash used in many programming languages, velocity is not
>> up to it yet (the tendency is not to make it into a programming
>> language).
>
> I don't have the slightest problem with that (but the again I'm not a
> doxia developer either ;-).
>
>> To my knowledge escaping of quotes was never supported by Velocity.
>
> My guess is it works with Velocity 1.5 or otherwise the doxia folks
> wouldn't be using it that way.  At least the parser doesn't choke on the
> template in question.

I'm 99.2% sure this never worked.  It probably just didn't break in
the same way, as you suggest.

>> So in the doxia case either use a single quote for the XML attributes,
>> or double-up the quotes, or use the poor-mans-escaping (TM):
>>   #set( $Q = '"' )
>
> I'll take this advice to the doxia people and see whether they want to
> adapt.  "It works for 1.5 and we are not going to upgrade anyway" may be
> an alternative answer.

Only if by "works" you mean "fails with insufficient notice".  I
recommend Velocity 1.7 and doubling up the quotes.

> Thank you for the feedback
>
>      Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>

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


Re: Potential Regression? Escaped Quotes in String Literals

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-08-02, <ap...@recks.org> wrote:

> even though I would love to have the established character escaping
> with a backslash used in many programming languages, velocity is not
> up to it yet (the tendency is not to make it into a programming
> language).

I don't have the slightest problem with that (but the again I'm not a
doxia developer either ;-).

> To my knowledge escaping of quotes was never supported by Velocity.

My guess is it works with Velocity 1.5 or otherwise the doxia folks
wouldn't be using it that way.  At least the parser doesn't choke on the
template in question.

> So in the doxia case either use a single quote for the XML attributes,
> or double-up the quotes, or use the poor-mans-escaping (TM):
>   #set( $Q = '"' )

I'll take this advice to the doxia people and see whether they want to
adapt.  "It works for 1.5 and we are not going to upgrade anyway" may be
an alternative answer.

Thank you for the feedback

      Stefan

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


Re: Potential Regression? Escaped Quotes in String Literals

Posted by ap...@recks.org.
Hi,

even though I would love to have the established character escaping with a backslash used in many programming languages, velocity is not up to it yet (the tendency is not to make it into a programming language).

Some time ago it was chosen to allow embedded double-quotes in a string by doubling it up - as done e.g. in CVS exports and some other M$-near string tools.

To my knowledge escaping of quotes was never supported by Velocity. Only literals can be escaped - with some curiosities - see the User Manual "Escaping Valid VTL References".

So in the doxia case either use a single quote for the XML attributes, or double-up the quotes, or use the poor-mans-escaping (TM):
  #set( $Q = '"' )

Kind regards,
Christoph

On 2010-08-02 06:18, Stefan Bodewig wrote:
> Hi all,
> 
> there is a build failure showing up in some Gump builds that seems to
> indicate a backwards incompatible change inside Velocity - which may or
> may not be intentional.
> 
> One example of the failure can be seen in the Cargo build
> <http://vmgump.apache.org/gump/public/cargo/cargo/gump_work/build_cargo_cargo.html>.
> I'll be happy to explain what Gump does, but the failure itself can be
> understood without that background.
> 
> The doxia-site-renderer Maven module contains a Velocity template which
> itself contains a line
> 
>         #set ( $documentHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" )
> 
> probably with the expectaation that \" would escape the quote.  This
> seems to work with the version referenced by the module: 1.5.
> 
> If you try to parse the same template with the trunk of Velocity engine
> you get
> 
> [ERROR] org.apache.velocity.exception.ParseErrorException: Encountered "1.0" at org/apache/maven/doxia/siterenderer/resources/default-site.vm[line 308, column 51]
> Was expecting one of:
>     <RPAREN> ...
>     <WHITESPACE> ...
> 
> which looks as if the " before 1.0 was terminating the string literal.
> 
> I can't find any hint in Velocity's documentation that would say you can
> escape quotes in string literals, but if it worked in older versions you
> are setting some sort of expectation 8-)
> 
> Is this a regression that can/will be fixed or is this something the
> downstream users like doxia would need to adapt to?
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
> 

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