You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Nicolas Lenoire (Jira)" <ji...@apache.org> on 2021/06/16 20:06:00 UTC

[jira] [Comment Edited] (CXF-8553) UriBuilder does not properly encode query parameters

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

Nicolas Lenoire edited comment on CXF-8553 at 6/16/21, 8:05 PM:
----------------------------------------------------------------

Hello [~ffang],

Thanks for your answer.

I'm not sure to understand the rational for this "partial encoding" from CXF. It causes encoding troubles from our side, and seems to be undocumented.

One of our use case is as follow: end user defines a sql condition that became a query param in the URL. This query param is properly decoded by CXF. Our backend then needs to provide back a pagination URL containing this query param in its response. For this we construct the next page URL using the UriBuilder class. A typical sql condition might be *Address LIKE '%250%'*. I have tried to pre-encode the parameter value before using UrlBuilder, but then I'm facing double encoding issue.

Please, provide a reliable solution to our use case.

 

Thanks,

Nicolas


was (Author: nlenoire):
Hello [~ffang],

Thanks for your answer.

I'm not sure to understand the rational for this "partial encoding" from CXF. It causes encoding troubles from our side, and seems to be undocumented.

One of our use case is as follow: end user defines a sql condition that became a query param in the URL. This query param is properly decoded by CXF. Our backend then needs to provide back a pagination URL containing this query param in its response. For this we construct the next page URL using the UriBuilder class. A typical sql condition might be *Address LIKE '%250%'*. I have tried to pre-encode the parameter value before using UrlBuilder, but then I'm facing double encoding issue.

Please, provide a suitable solution to our use case.

 

Thanks,

Nicolas

> 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)