Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B6A8310A60 for ; Mon, 1 Dec 2014 18:32:13 +0000 (UTC) Received: (qmail 7534 invoked by uid 500); 1 Dec 2014 18:32:12 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 7440 invoked by uid 500); 1 Dec 2014 18:32:12 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 7177 invoked by uid 99); 1 Dec 2014 18:32:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Dec 2014 18:32:12 +0000 Date: Mon, 1 Dec 2014 18:32:12 +0000 (UTC) From: "Konrad Windszus (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-6122) JAX-RS proxy client with @QueryParam is not encoding the parameter value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-6122?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D142301= 92#comment-14230192 ]=20 Konrad Windszus edited comment on CXF-6122 at 12/1/14 6:31 PM: --------------------------------------------------------------- This will not work either, as the replacePath will do an additional escapin= g on the already URL encoded query. {code} private static final String ADMIN_PREFIX =3D "/admin"; @Test =09public void testStripAdminPrefixFromUri() throws URISyntaxException, Uns= upportedEncodingException { =09=09String authority =3D "www.test.com"; =09=09String value =3D "+ =C3=84=C3=96=C3=9C value"; =09=09String path =3D "/admin/path"; =09=09String query =3D "param=3D" + URLEncoder.encode(value, "UTF-8"); =09=09URI oldUri =3D new URI("http", authority, path, query, null); =09=09URI newUri =3D stripAdminPrefixFromUri(oldUri); =09=09 =09=09Assert.assertThat(newUri.getPath(), Matchers.equalTo("/path")); =09=09String newQuery =3D newUri.getRawQuery(); =09=09String encodedValue =3D newQuery.substring("param=3D".length()); // this will fail already due to the double escaping here =09=09Assert.assertThat(URLDecoder.decode(encodedValue, "UTF-8"), Matchers.= equalTo(value)); =09=09Assert.assertThat(newUri.getRawQuery(), Matchers.equalTo(oldUri.getRa= wQuery())); =09=09 =09} =09 =09protected static URI stripAdminPrefixFromUri(URI uri) { =09=09String path =3D uri.getPath().substring(ADMIN_PREFIX.length()); =09=09URI newUri =3D UriBuilder.fromUri(uri).replacePath(path).build(); =09=09//URI newUri =3D new URI(uri.getScheme(), uri.getAuthority(), path, u= ri.getQuery(), uri.getRawFragment()); =09=09return newUri; =09} {code} Just execute the attached test case to verify that. was (Author: kwin): This will not work either, as the replacePath will do an additional escapin= g on the already URL encoded query. {code} @Test =09public void testStripAdminPrefixFromUri() throws URISyntaxException, Uns= upportedEncodingException { =09=09String authority =3D "www.test.com"; =09=09String value =3D "+ =C3=84=C3=96=C3=9C value"; =09=09String path =3D "/admin/path"; =09=09String query =3D "param=3D" + URLEncoder.encode(value, "UTF-8"); =09=09URI oldUri =3D new URI("http", authority, path, query, null); =09=09URI newUri =3D stripAdminPrefixFromUri(oldUri); =09=09 =09=09Assert.assertThat(newUri.getPath(), Matchers.equalTo("/path")); =09=09String newQuery =3D newUri.getRawQuery(); =09=09String encodedValue =3D newQuery.substring("param=3D".length()); // this will fail already due to the double escaping here =09=09Assert.assertThat(URLDecoder.decode(encodedValue, "UTF-8"), Matchers.= equalTo(value)); =09=09Assert.assertThat(newUri.getRawQuery(), Matchers.equalTo(oldUri.getRa= wQuery())); =09=09 =09} =09 =09protected static URI stripAdminPrefixFromUri(URI uri) { =09=09String path =3D uri.getPath().substring(ADMIN_PREFIX.length()); =09=09URI newUri =3D UriBuilder.fromUri(uri).replacePath(path).build(); =09=09//URI newUri =3D new URI(uri.getScheme(), uri.getAuthority(), path, u= ri.getQuery(), uri.getRawFragment()); =09=09return newUri; =09} {code} Just execute the attached test case to verify that. > JAX-RS proxy client with @QueryParam is not encoding the parameter value > ------------------------------------------------------------------------ > > Key: CXF-6122 > URL: https://issues.apache.org/jira/browse/CXF-6122 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.0.2 > Reporter: Konrad Windszus > > If I create a JAX-RS client with the proxy pattern outlined at http://cxf= .apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-Proxy-basedAPI and = the proxy interface looks like this > {code} > @PUT > =09@Path("/admin/user/{id}.json") > =09@Produces(value =3D { "application/json" }) > =09public User updateUser(@PathParam("id") String userId, @QueryParam("co= untry") String country, @QueryParam("description") String role, @QueryParam= ("telephone") String phone); > {code} > all URL parameters are not correctly encoded. > E.g. if phone contains a "+" this will not be converted to %2B or if the = role contains an umlaut this will not be encoded either. > Another related question is: Which character set will be used here (I gue= ss UTF-8 makes sense) once that bug is fixed? Also how would it be possible= to override the character set? -- This message was sent by Atlassian JIRA (v6.3.4#6332)