Bug in url decoder

777 views
Skip to first unread message

Tony Xiao

unread,
Mar 14, 2011, 6:26:04 PM3/14/11
to play-fr...@googlegroups.com
This seems like a bug to me, but can someone else confirm?

I'm entering the following url in the browser 

http://localhost:9000/search?q="Adjusted net savings, excluding particulate emission damage (% of GNI) (Al"

which gets translated by the browser into 


and on the play front I simply have a controller that takes in a single string parameter q

and I get the following error

18:24:57,240 ERROR ~ 

@65mg63nl7
Trying to flush cookies

Oops: IllegalArgumentException
An unexpected error occured caused by exception IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "%2"

play.exceptions.UnexpectedException: Unexpected Error
at play.server.PlayHandler.serve500(PlayHandler.java:581)
at Invocation.Message Received(Play!)
Caused by: java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "%2"
at java.net.URLDecoder.decode(Unknown Source)
at play.server.PlayHandler.parseRequest(PlayHandler.java:400)
... 1 more


Any ideas?

Nicolas Girardin

unread,
Mar 15, 2011, 5:01:18 AM3/15/11
to play-fr...@googlegroups.com
Hi Tony,

I think that the % character in "% of GNI" should be escaped to %25
(which is the code for the percent character). You shouldn't have
unescaped % in your URL.

Is the bug still present using the
http://localhost:9000/search?q=Adjusted%20net%20savings,%20excluding%20particulate%20emission%20damage%20(%25%20of%20GNI)%20(Al
URL?

Nicolas

2011/3/14 Tony Xiao <tony...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

Florian Gutmann

unread,
Mar 15, 2011, 5:03:57 AM3/15/11
to play-fr...@googlegroups.com
The problem is not on the play side. The url is encoded incorrectly.
The % sign in the parameter should be encoded as %25.

Try: http://localhost:9000/search?q=Adjusted%20net%20savings,%20excluding%20particulate%20emission%20damage%20(%25%20of%20GNI)%20(Al
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

-- 
Florian Gutmann

Steve Chaloner

unread,
Mar 15, 2011, 5:06:25 AM3/15/11
to play-framework
Try using something like http://plugins.jquery.com/project/URLEncode
to encode your request parameter.

- Steve

On Mar 15, 10:01 am, Nicolas Girardin <ngirar...@gmail.com> wrote:
> Hi Tony,
>
> I think that the % character in "% of GNI" should be escaped to %25
> (which is the code for the percent character). You shouldn't have
> unescaped % in your URL.
>
> Is the bug still present using thehttp://localhost:9000/search?q=Adjusted%20net%20savings,%20excluding%...
> URL?
>
> Nicolas
>
> 2011/3/14 Tony Xiao <tonyx...@gmail.com>:
>
> > This seems like a bug to me, but can someone else confirm?
> > I'm entering the following url in the browser
> >http://localhost:9000/search?q="Adjusted net savings, excluding particulate
> > emission damage (% of GNI) (Al"
>
> > which gets translated by the browser into
> >http://localhost:9000/search?q=Adjusted%20net%20savings,%20excluding%...

Tony Xiao

unread,
Mar 15, 2011, 7:48:30 AM3/15/11
to play-fr...@googlegroups.com
Hi Nicolas,

The problem is indeed the encoding and I can confirm that the above url solves the problem.

So it seems that it's the browser that failed to encode the string properly, since I'm entering the parameter q directly into the location field of the browser (not processed through javascript or anything) and the browser properly encoded spaces but no the % sign.

Tony Xiao

unread,
Mar 15, 2011, 7:49:18 AM3/15/11
to play-fr...@googlegroups.com
Got it, thanks guys!

Nicolas Girardin

unread,
Mar 15, 2011, 8:33:46 AM3/15/11
to play-fr...@googlegroups.com
I'm very pleased that it helps! :)

I pasted the URL in Chromium which didn't converted the % sign. Maybe
could you report the bug to them ;)

Nicolas


2011/3/15 Tony Xiao <tony...@gmail.com>:
> Got it, thanks guys!

Reply all
Reply to author
Forward
0 new messages