You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/06/03 18:43:22 UTC

[cxf] branch 3.3.x-fixes updated (59201ec -> c45e5f0)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 59201ec  Recording .gitmergeinfo Changes
     new 2886bb3  CXF-8387: Allow special characters to be used for a queryParam name. (#809)
     new c45e5f0  Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |   4 +
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     |   6 +-
 .../apache/cxf/jaxrs/impl/UriBuilderImplTest.java  | 111 +++++++++++++++++++++
 .../org/apache/cxf/systest/jaxrs/BookStore.java    |  11 ++
 .../systest/jaxrs/JAXRS20ClientServerBookTest.java |  23 +++++
 5 files changed, 154 insertions(+), 1 deletion(-)

[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit c45e5f0e1b242b502acb1b4540756c334bf4b9a8
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Thu Jun 3 14:29:24 2021 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 057a2b4..74a30e5 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -57,6 +57,7 @@ B 16c1d31b17b310d32d24676d3aca9c2b80c866ee
 B 16e0e3d42fa3cb27fa289cbfe87f90855649dc32
 B 16e862032f3de1cf52a5b28e099cd35b7ce7b7ce
 B 16fd14766b0b389e51f1214662cddda560c05f3f
+B 172fa7ac6908096d546e154cb81aec6a0a6f2dbd
 B 180fbbbd5571840b5f7a09ab7c0ce59605edd346
 B 1846348f9fff03e91180f79b84957673a5bdbe22
 B 18671fba2b3f2a32e21aef43e038aa98879c7481
@@ -722,6 +723,7 @@ M 22a365b929822d1dbe157e0f22d228cfec21e6e2
 M 267b84c59053de915b2e783daf9a236a7b5df00b
 M 2696ea28b67f21b310e400b990da50016b62bd90
 M 269c7c8fe4553c5307fd938dbba51af5a1535482
+M 27e523b5c60ed48149b9433ead900224f17b6d0a
 M 29482be8df227ddbcac01e957c84e4807211865d
 M 299d6a844b99a69555355b2f9baca3e6ec13a918
 M 29f9d03b69ee071d3b83e4f0509a6b6e01b96564
@@ -831,6 +833,7 @@ M 8100e4d9512b2fd9ce2fe30a4b7feeaab1d691a5
 M 81d82da19ed43bbeaae12a7eda052a64890ec970
 M 83c9d2701fbf4ed54bd704ca7c4cf67f57e1048d
 M 84bc3830fb3d320f843b43d86e90d8a7e7e871d4
+M 85225069fe57849cbfac1b039014ce195a1d3bb5
 M 8532499404623bd531147ee314ec65544cab34de
 M 8798b83cef186439b72ff02d9bafa37f9658404e
 M 88907f141ee80792627da3cc7846d1562f6c0238
@@ -839,6 +842,7 @@ M 8ad7a9bbe1d9c257ff0ca9e99862095c9be7302d
 M 8b11d6b26369650e5f4c6f3730dbb97d60927d9b
 M 8b67b6f672d25f1128924e8aac58a6f395fe3511
 M 8c4f04855a5d8623daff2aa8a8856367879c624b
+M 8d06ec6873737ebf5d1d08d494dce0ecbec65d74
 M 8d10e2ed1a2b2d56b0d1ad750bf576a1f06bb084
 M 90cad919d00dad2aaeede8f8475c14e2c2e76ad0
 M 90dc0e39fc9c1b1cb2da4558a3bdf51e16fe6877

[cxf] 01/02: CXF-8387: Allow special characters to be used for a queryParam name. (#809)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 2886bb33b0045a93f97dadbae2074796e2a749c2
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Thu Jun 3 09:27:11 2021 -0400

    CXF-8387: Allow special characters to be used for a queryParam name. (#809)
    
    * CXF-8387: Allow special characters to be used for a queryParam name.
    
    * Added a bit more test cases with templating
    
    (cherry picked from commit 88de27ade27695a295d392ef8cea96b72f841481)
    (cherry picked from commit d3ef8cc4a81fafbd09781806465c9bfc1f6d2014)
---
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java     |   6 +-
 .../apache/cxf/jaxrs/impl/UriBuilderImplTest.java  | 111 +++++++++++++++++++++
 .../org/apache/cxf/systest/jaxrs/BookStore.java    |  11 ++
 .../systest/jaxrs/JAXRS20ClientServerBookTest.java |  23 +++++
 4 files changed, 150 insertions(+), 1 deletion(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index fdf52ed..52a8bf1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -1360,7 +1360,11 @@ public final class JAXRSUtils {
             }
         }
 
-        queries.add(HttpUtils.urlDecode(name), value);
+        if (decode) {
+            queries.add(HttpUtils.urlDecode(name), value);
+        } else {
+            queries.add(name, value);
+        }
     }
 
     private static Object readFromMessageBody(Class<?> targetTypeClass,
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
index 197e724..0fc683e 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxrs.impl;
 
 import java.lang.reflect.Method;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -1721,4 +1722,114 @@ public class UriBuilderImplTest {
         }
 
     }
+    
+    @Test
+    public void testURIWithSpecialCharacters() {
+        final String expected = "http://localhost:8080/xy%22";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .path(URLEncoder.encode("xy\"")).build();
+        
+        assertEquals(expected, uri.toString());
+    }
+
+    @Test
+    public void testURIWithSpecialCharacters2() {
+        final String expected = "http://localhost:8080/xy%09";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .path(URLEncoder.encode("xy\t"))
+            .buildFromEncoded();
+        
+        assertEquals(expected, uri.toString());
+    }
+
+    @Test
+    public void testURIWithSpecialCharactersPreservePath() {
+        final String expected = "http://localhost:8080/xy/%22/abc";
+        
+        final URI uri = UriBuilder.fromPath("")
+            .replacePath("http://localhost:8080")
+            .path("/{a}/{b}/{c}")
+            .buildFromEncoded("xy", "\"", "abc");
+        
+        assertEquals(expected, uri.toString());
+    }
+
+    @Test
+    public void testURIWithSpecialCharactersPreservePath2() {
+        final String expected = "http://localhost:8080/xy/%09/abc";
+        
+        final URI uri = UriBuilder.fromPath("")
+            .replacePath("http://localhost:8080")
+            .path("/{a}/{b}/{c}")
+            .buildFromEncoded("xy", "\t", "abc");
+        
+        assertEquals(expected, uri.toString());
+    }
+
+    @Test
+    public void testIllegalURI() {
+        final String path = "invalidpath";
+        
+        final URI uri = UriBuilder
+            .fromPath(path)
+            .build();
+        
+        assertEquals(path, uri.toString());
+    }
+    
+    @Test
+    @SuppressWarnings({"checkstyle:linelength"})
+    public void queryParamSpecialCharacters() {
+        final String expected = "http://localhost:8080?%2F%3FabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._%7E%251A%21%24%27%28%29*%2B%2C%3B%3A%40=apiKeyQueryParam1Value";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .queryParam(URLEncoder.encode("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@"), "apiKeyQueryParam1Value")
+            .build();
+        
+        assertEquals(expected, uri.toString());
+    }
+    
+    @Test
+    @SuppressWarnings({"checkstyle:linelength"})
+    public void queryParamSpecialCharactersFromEncoded() {
+        final String expected = "http://localhost:8080?%2F%3FabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._%7E%251A%21%24%27%28%29*%2B%2C%3B%3A%40=apiKeyQueryParam1Value";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .queryParam(URLEncoder.encode("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@"), "apiKeyQueryParam1Value")
+            .buildFromEncoded();
+        
+        assertEquals(expected, uri.toString());
+    }
+    
+    @Test
+    @SuppressWarnings({"checkstyle:linelength"})
+    public void queryParamSpecialCharactersFromEncodedTemplate() {
+        final String expected = "http://localhost:8080?%2F%3FabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._%7E%251A%21%24%27%28%29*%2B%2C%3B%3A%40=apiKeyQueryParam1Value";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .queryParam("{a}", "{b}")
+            .buildFromEncoded(URLEncoder.encode("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@"), "apiKeyQueryParam1Value");
+        
+        assertEquals(expected, uri.toString());
+    }
+    
+    @Test
+    @SuppressWarnings({"checkstyle:linelength"})
+    public void queryParamSpecialCharactersFromTemplate() {
+        final String expected = "http://localhost:8080?/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._%7E%251A%21%24%27%28%29*%2B,%3B%3A%40=apiKeyQueryParam1Value";
+        
+        final URI uri = UriBuilder
+            .fromUri("http://localhost:8080")
+            .queryParam("{a}", "{b}")
+            .build("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@", "apiKeyQueryParam1Value");
+        
+        assertEquals(expected, uri.toString());
+    }
 }
\ No newline at end of file
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 20f5560..e601712 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -1798,6 +1798,17 @@ public class BookStore {
     public Response echoEntity(String entity) {
         return Response.ok().entity(entity).build();
     }
+    
+    @GET
+    @Path("/queryParamSpecialCharacters")
+    @Produces("text/plain")
+    @SuppressWarnings({"checkstyle:linelength"})
+    public Response queryParamSpecialCharacters(@QueryParam("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@") String queryParm1) {
+        return Response
+            .ok(queryParm1)
+            .type(MediaType.TEXT_PLAIN)
+            .build();
+    }
 
     public final String init() {
         books.clear();
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index ead9898..3a2e996 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.Collections;
@@ -926,6 +927,28 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
         }
     }
 
+    @Test
+    @SuppressWarnings({"checkstyle:linelength"})
+    public void testQueryParamSpecialCharactersEncoded() throws Exception {
+        final String address = "http://localhost:" + PORT + "/bookstore/queryParamSpecialCharacters";
+
+        try (Response response = ClientBuilder.newClient()
+                .register(AddHeaderClientResponseFilter.class)
+                .target(address)
+                .queryParam(URLEncoder.encode("/?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~%1A!$'()*+,;:@"), 
+                    "apiKeyQueryParam1Value")
+                .request(MediaType.TEXT_PLAIN)
+                .get()) {
+            assertEquals(200, response.getStatus());
+            
+            final String actual = response.readEntity(String.class);
+            final String expected = "apiKeyQueryParam1Value";
+            
+            assertEquals(expected, actual);
+        }
+    }
+
+
     private static class ReplaceBodyFilter implements ClientRequestFilter {
 
         @Override