You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/02/17 19:36:43 UTC

svn commit: r1071743 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/

Author: sergeyb
Date: Thu Feb 17 18:36:43 2011
New Revision: 1071743

URL: http://svn.apache.org/viewvc?rev=1071743&view=rev
Log:
[CXF-3226] Colons in path segments should not be url encoded by default

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1071743&r1=1071742&r2=1071743&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Thu Feb 17 18:36:43 2011
@@ -63,7 +63,7 @@ public final class HttpUtils {
     private static final String CHARSET_PARAMETER = "charset";
     
     // there are more of such characters, ex, '*' but '*' is not affected by UrlEncode
-    private static final String PATH_RESERVED_CHARACTERS = "=@/";
+    private static final String PATH_RESERVED_CHARACTERS = "=@/:";
     private static final String QUERY_RESERVED_CHARACTERS = "?/";
     
     private HttpUtils() {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1071743&r1=1071742&r2=1071743&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Thu Feb 17 18:36:43 2011
@@ -112,6 +112,15 @@ public class BookStore {
         System.out.println("PreDestroy called");
     }
     
+    @GET
+    @Path("/books/colon/{a}:{b}:{c}")
+    @Produces("application/xml")
+    public Book getBookWithColonMarks(@PathParam("a") String id1,
+                                      @PathParam("b") String id2,
+                                      @PathParam("c") String id3) throws BookNotFoundFault {
+        return doGetBook(id1 + id2 + id3);
+    }
+    
     @POST
     @Path("emptypost")
     public void emptypost() {
@@ -407,6 +416,8 @@ public class BookStore {
         return doGetBook(id);
     }
     
+    
+    
     @GET
     @Path("/books/response/{bookId}/")
     @Produces("application/xml")

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1071743&r1=1071742&r2=1071743&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Thu Feb 17 18:36:43 2011
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -79,6 +80,25 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetBookWithColonMarks() throws Exception {
+        
+        // URLEncoder will turn ":" into "%3A" but ':' is actually
+        // not disallowed in the path components 
+        String endpointAddressUrlEncoded =
+            "http://localhost:" + PORT + "/bookstore/books/colon/" 
+            + URLEncoder.encode("1:2:3", "UTF-8");
+        
+        Response r = WebClient.create(endpointAddressUrlEncoded).get();
+        assertEquals(404, r.getStatus());
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/bookstore/books/colon/1:2:3";
+        WebClient wc = WebClient.create(endpointAddress);
+        Book b = wc.get(Book.class);
+        assertEquals(123L, b.getId());
+    }
+    
+    @Test
     public void testPostAnd401WithText() throws Exception {
         
         String endpointAddress =