You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/01/20 06:18:13 UTC

[camel] branch camel-3.14.x updated: CAMEL-17452 Fix bug in URISupport#sanitizeUri (#6791)

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

davsclaus pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.14.x by this push:
     new 4589fab  CAMEL-17452 Fix bug in URISupport#sanitizeUri (#6791)
4589fab is described below

commit 4589fab1104e223c4531f694e54085d10a29c189
Author: Claus Skou Nielsen <ka...@gmail.com>
AuthorDate: Thu Jan 20 07:07:14 2022 +0100

    CAMEL-17452 Fix bug in URISupport#sanitizeUri (#6791)
---
 .../src/main/java/org/apache/camel/util/URISupport.java      |  2 +-
 .../src/test/java/org/apache/camel/util/URISupportTest.java  | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
index d627034..33302a1 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
@@ -43,7 +43,7 @@ public final class URISupport {
     // "passphrase" or "password" or secret key (case-insensitive).
     // First capture group is the key, second is the value.
     private static final Pattern SECRETS = Pattern.compile(
-            "([?&][^=]*(?:passphrase|password|secretKey|accessToken|clientSecret|authorizationToken|saslJaasConfig)[^=]*)=(RAW[({].*[)}]|[^&]*)",
+            "([?&][^=]*(?:passphrase|password|secretKey|accessToken|clientSecret|authorizationToken|saslJaasConfig)[^=]*)=(RAW(([{][^}]*[}])|([(][^)]*[)]))|[^&]*)",
             Pattern.CASE_INSENSITIVE);
 
     // Match the user password in the URI as second capture group
diff --git a/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java b/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
index 7d49250..92bc58f 100644
--- a/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
+++ b/core/camel-util/src/test/java/org/apache/camel/util/URISupportTest.java
@@ -316,6 +316,18 @@ public class URISupportTest {
     }
 
     @Test
+    public void testSanitizeUriWithRawPasswordAndSimpleExpression() {
+        String uriPlain
+                = "http://foo?username=me&password=RAW(me#@123)&foo=bar&port=21&tempFileName=${file:name.noext}.tmp&anotherOption=true";
+        String uriCurly
+                = "http://foo?username=me&password=RAW{me#@123}&foo=bar&port=21&tempFileName=${file:name.noext}.tmp&anotherOption=true";
+        String expected
+                = "http://foo?username=me&password=xxxxxx&foo=bar&port=21&tempFileName=${file:name.noext}.tmp&anotherOption=true";
+        assertEquals(expected, URISupport.sanitizeUri(uriPlain));
+        assertEquals(expected, URISupport.sanitizeUri(uriCurly));
+    }
+
+    @Test
     public void testSanitizeSaslJaasConfig() throws Exception {
         String out1 = URISupport.sanitizeUri(
                 "kafka://MY-TOPIC-NAME?saslJaasConfig=org.apache.kafka.common.security.plain.PlainLoginModule required username=scott password=tiger");