[ 
https://issues.apache.org/jira/browse/CXF-8553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17364508#comment-17364508
 ] 

Freeman Yue Fang commented on CXF-8553:
---------------------------------------

Hi [~nlenoire],

IMO what CXF do in encodePartiallyEncoded is to avoid double encoding issue. 
CXF assumes that "%" + "two hexadecimal digits" is already encoded, so that it 
won't encode the "%" twice which fall this "%" + "two hexadecimal digits" 
pattern. Think about one user passes in %20 to represent an encoded space char, 
in this case CXF won't encode the first char % in "%20", which is expected. So 
CXF's assumption is right for some cases, but not perfectly right for other 
cases(like yours). However, the problem is that CXF can't know when should 
encode the "%" in "%20", so the choice was left to end users.  In your case, 
you have input like '%250%', but the first "%" is followed by "25" which falls 
in the pattern that CXF won't encode the "%",  so to be able to get the result 
you want, you need to encode the first "%" by yourself, so the input should be 
"%25250%". The the second "%" can be encoded by CXF, so the input will become 
"%25250%25" eventually.

Hope this helps!
Freeman



> UriBuilder does not properly encode query parameters
> ----------------------------------------------------
>
>                 Key: CXF-8553
>                 URL: https://issues.apache.org/jira/browse/CXF-8553
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.4.3
>            Reporter: Nicolas Lenoire
>            Assignee: Freeman Yue Fang
>            Priority: Major
>
> The JAXRS specification seems unclear regarding how the method
> {code:java}
> UriBuilder.queryParam(String name, Object… values){code}
> treats values w/ URL encoding. However, we could legitimately assume this 
> method properly URL encodes parameter values.
> CXF implementation URL encodes values, but with some defects:
> invoking
> {code:java}UriBuilder.fromUri("my/path").queryParam("p", 
> "%250%").toTemplate(){code}
> produces the URI template
> {code:java}
> my/path?p=%250%25 {code}
> instead of
> {code:java}
> my/path?p=%25250%25{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to