[
https://issues.apache.org/jira/browse/CXF-8553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17364620#comment-17364620
]
Andriy Redko commented on CXF-8553:
-----------------------------------
Hi [~nlenoire] ,
Thanks for bringing this one up, I hope to clarify a few things, additionally
to what [~ffang] already said. But first of all, there is a simple solution
specifically for your problem using template parameters:
{code:java}
UriBuilder
.fromUri("my/path")
.queryParam("p", "{p}")
.resolveTemplate("p", "%250%")
.toTemplate() {code}
It produces exactly the results you would have expected:
{code:java}
my/path?p=%25250%25 {code}
Regarding the encoding thing: indeed as [~ffang] mentioned, CXF treats the
presence of `%` character as value being encoded (may be partially encoded) so
it tries to finalize the encoding, this is why you see the `%250%25` as the
result. Also, you rightly pointed out, the JAX-RS specification is unclear in
this respect (this is why we have TCKs on top) but we could definitely document
the CXF's take on that.
Hope it helps.
> 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)