users@jersey.java.net

[Jersey] Re: interesting path parameter behavior with URL encoded strings

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Thu, 26 Apr 2012 14:38:36 +0200

Hi, can you file an issue in Jersey Jira ( http://java.net/jira/browse/jersey ) ? Also, seems you might have a reproducible test case already. If so, can you please attach it to the issue?

Thanks,
Marek

On Apr 20, 2012, at 12:36 AM, Michael Frank wrote:

> I'm writing a Resource where you could pass in URL encoded strings as path parameters. What I have found is that this doesn't always work.
>
> My path annotation is: @Path("/list/add/{value}")
>
> My listener method looks like public Response addToList(@PathParam("value") String value)
>
> What I have found is calling this resource with the url /list/add/one%20two works as I'd expect. It creates the variable value with the string "one two".
>
> However if I call this resource with the url /list/add/one%2Ftwo then I get a 400 Bad Request response and the listener is never called. What is fun is that calling /list/add/one/two will actually work in this case since the regex matching is greedy. In my case I'm passing in whole URLs. So passing /list/add/https://host.com/item/93939 will work and value will be set to https://host.com/item/93939 even though at this point I'm using unencoded reserved characters.
>
> All of these calls would be from a user's browser to my Jersey service. In my testing I'm using Firefox 3.6.12(yes its hella old, but it's all they'll give us at work for now).
>
> Thanks,~Mike~
>
>