users@jsr311.java.net

Re: JAX-RS: UriBuilder encoding

From: Stephan Koops <Stephan.Koops_at_web.de>
Date: Thu, 17 Jul 2008 11:19:37 +0200

Hi James, hi Marc,
>
> Use cases for an encoding mode like encoding=true, but where percent
> chars are NOT escaped (nicknamed “true-%”).
>
>
>
> Consider http://samplemerchant.info/uri/a%23b/résumé.html
> <http://samplemerchant.info/uri/a%23b/r%C3%A9sum%C3%A9.html>
>
>
>
> This email, current browsers (Safari, Internet Explorer, Firefox 3…),
> and the HTML source for that web page all display this web address in
> the same way – including the non-URI character é and the %23 escape
> sequence (escaping a ‘#’ so it can appear in the path).
>
>
>
> A cut-n-paste of this address (or just its path) from any of these
> sources should be accepted by JAX-RS. In particular, it should be
> accepted by UriBuilder path(…) and as @Path values.
>
>
>
> This is an example of a string that is NOT “either completely encoded
> or not encoded at all”. This situation will be increasingly common.
>
>
>
> With the current spec:
>
>
>
> UriBuilder.fromPath(“/uri/a%23b/résumé.html”, false) ->
> IllegalArgumentException
>
>
>
> UriBuilder.fromPath(“/uri/a%23b/résumé.html”, true).build() ->
> “/uri/a%2523b/r%C3%A9sum%C3%A9.html” -> 404 NOT FOUND
>
>
>
> In my suggested true-% mode
>
>
>
> UriBuilder.fromPath(“/uri/a%23b/résumé.html”).build() ->
> “/uri/a%23b/r%C3%A9sum%C3%A9.html” -> 200 OK -> @PathParam->
> “/uri/a#b/résumé.html”
>
Perhaps we a third mode is useful? I know, it makes it more complicated,
but I think we need it:

   1. no encode, only check (same as current false)
   2. encode everything, including '%' (what Marc intended for true)
   3. encode everything excluding valid percent encoded values
      (suggestion of James and also my understanding of true)


It could be explicit documented in the javadoc, that the both last are
equivalent, if no percent char is available. This reduces fear of
complexity by app developers.

Marc, if I remeber right, you talked about a next API version. When
should it come? Is it right, that this should not change?

best regards
   Stephan