You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/04/23 10:22:37 UTC

camel git commit: CAMEL-8607 Fixed the issue of Camel endpoint RAW password unsafe characters

Repository: camel
Updated Branches:
  refs/heads/master c68c78215 -> f5098d138


CAMEL-8607 Fixed the issue of Camel endpoint RAW password unsafe characters


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5098d13
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5098d13
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5098d13

Branch: refs/heads/master
Commit: f5098d13847933d8e2fc185bdad1e67366840bfb
Parents: c68c782
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Apr 23 16:22:27 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Apr 23 16:22:27 2015 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/camel/impl/DefaultComponent.java    | 3 ++-
 .../apache/camel/component/http4/HttpEndpointURLTest.java    | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5098d13/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
index a832e4d..c7ab7ff 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
@@ -64,7 +64,8 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone
         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);
+            // we just don't want to log the password setting here
+            LOG.warn("Supplied URI '{}' contains unsafe characters, please check encoding", URISupport.sanitizeUri(uri));
         }
         return encodedUri;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/f5098d13/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointURLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointURLTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointURLTest.java
index af09699..c86e5a6b 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointURLTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointURLTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.http4;
 
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.URISupport;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.junit.Test;
@@ -61,5 +62,12 @@ public class HttpEndpointURLTest extends CamelTestSupport {
         assertEquals("Get a wrong setting of maxTotalConnections", 40, poolManager.getMaxTotal());
         assertEquals("Get a wrong setting of connectionsPerRoute", 5, poolManager.getDefaultMaxPerRoute());
     }
+    
+    @Test
+    // Just for CAMEL-8607
+    public void testRawWithUnsafeCharacters() throws Exception {
+        HttpEndpoint http1 = context.getEndpoint("http4://www.google.com?authenticationPreemptive=true&authPassword=RAW(foo%bar)&authUsername=RAW(username)", HttpEndpoint.class);
+        assertTrue("The password is not loggged", URISupport.sanitizeUri(http1.getEndpointUri()).indexOf("authPassword=xxxxxx") > 0);
+    }
 
 }