camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1165796 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
Date Tue, 06 Sep 2011 19:31:58 GMT
Author: hadrian
Date: Tue Sep  6 19:31:57 2011
New Revision: 1165796

URL: http://svn.apache.org/viewvc?rev=1165796&view=rev
Log:
CAMEL-4405. Make sure Camel gets properly encoded URIs (and issue warning otherwise)

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=1165796&r1=1165795&r2=1165796&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java Tue Sep
 6 19:31:57 2011
@@ -54,8 +54,13 @@ public abstract class DefaultComponent e
 
     public Endpoint createEndpoint(String uri) throws Exception {
         ObjectHelper.notNull(getCamelContext(), "camelContext");
-        //encode URI string to the unsafe URI characters
-        URI u = new URI(UnsafeUriCharactersEncoder.encode(uri));
+        // check URI string to the unsafe URI characters
+        String encodedUri = UnsafeUriCharactersEncoder.encode(uri);
+        if (!encodedUri.equals(uri)) {
+            // uri supplied is not really valid
+            LOG.warn("Supplied URI '{}' contains unsafe characters, please check encoding",
uri);
+        }
+        URI u = new URI(encodedUri);
         String path = u.getSchemeSpecificPart();
 
         // lets trim off any query arguments
@@ -87,11 +92,11 @@ public abstract class DefaultComponent e
             // if endpoint is strict (not lenient) and we have unknown parameters configured
then
             // fail if there are parameters that could not be set, then they are probably
misspell or not supported at all
             if (!endpoint.isLenientProperties()) {
-                validateParameters(uri, parameters, null);
+                validateParameters(encodedUri, parameters, null);
             }
         }
 
-        afterConfiguration(uri, path, endpoint, parameters);
+        afterConfiguration(encodedUri, path, endpoint, parameters);
         return endpoint;
     }
 

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java?rev=1165796&r1=1165795&r2=1165796&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
Tue Sep  6 19:31:57 2011
@@ -27,8 +27,8 @@ public class CxfRsEndpointTest extends C
     @Test
     public void testCreateCxfRsEndpoint() throws Exception {
         String endpointUri = "cxfrs://http://localhost:" + CTX + ""
-            + "?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService,
"
-            + "java.lang.String ; org.apache.camel.component.cxf.jaxrs.testbean.Order";
+            + "?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService,"
+            + "java.lang.String;org.apache.camel.component.cxf.jaxrs.testbean.Order";
         CxfRsComponent component = new CxfRsComponent(context);
         CxfRsEndpoint endpoint = (CxfRsEndpoint)component.createEndpoint(endpointUri);
         



Mime
View raw message