Re: URL encoding and the "+" char

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
In a somewhat related question, any idea why do we have StringUtil.URLEnc and are not simply using java.net.URLEncoder?

Attila.

On 2010.06.02., at 9:54, Daniel Dekany wrote:

> Wednesday, June 2, 2010, 12:08:39 AM, Dan Washusen wrote:
> 
>> Hey All,
>> I'm attempting to add a base64 encoded string as a URL parameter in a FM template.
>> 
>> <a id="activate" href="action?token=${token?url}">Click Here</a>
>> 
>> This works fine but it appears that the Freemarker URL encoding
>> doesn't encode the "+" chars contained in the token.  When I attempt
>> to decode the token using either commons-codec or the
>> java.util.URLDecoder the "+" is replaced by a space (" ") and my token is corrupt.
>> 
>> So I guess my question is; is this a bug or a feature?  
> 
> That would be a major bug, as ?url is for escaping query parameters.
> But for me it works. This is the template I tried:
> 
>  <#setting url_escaping_charset='utf-8'>
>  ${.version}
>  ${"a/b+c d"?url}
> 
> and its output was:
> 
>  2.3.16
>  a%2Fb%2Bc%20d
> 
> What is the output on your setup? (Note that I didn't even find any
> version history entry that says that ?url had a bug in earlier
> FreeMarker versions.)
> 
>> Cheers,
>> Dan
> 
> -- 
> Best regards,
> Daniel Dekany





------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.