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

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


The following commit(s) were added to refs/heads/camel-3.18.x by this push:
     new bcc9cb4f303 CAMEL-18834: camel-core - StringQuoteHelper should remove 
quotes for … (#8941) (#10097)
bcc9cb4f303 is described below

commit bcc9cb4f3039a7ea74eb00c78b660acb05e884f5
Author: Zheng Feng <[email protected]>
AuthorDate: Tue May 16 15:03:05 2023 +0800

    CAMEL-18834: camel-core - StringQuoteHelper should remove quotes for … 
(#8941) (#10097)
    
    CAMEL-18834: camel-core - StringQuoteHelper should remove quotes for single 
element
    
    Co-authored-by: Claus Ibsen <[email protected]>
---
 .../apache/camel/util/StingQuoteHelperTest.java    | 34 ++++++++++++++++++++++
 .../camel/support/PropertyBindingSupport.java      |  4 +--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java 
b/core/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java
index 94fcde44563..2c9efbdddf7 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/util/StingQuoteHelperTest.java
@@ -124,6 +124,40 @@ public class StingQuoteHelperTest {
         assertEquals("*", out[0]);
         assertEquals("", out[1]);
         assertEquals("arg3", out[2]);
+
+        out = StringQuoteHelper.splitSafeQuote("'Hello'", ',', true);
+        assertEquals(1, out.length);
+        assertEquals("Hello", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("' Hello '", ',', true);
+        assertEquals(1, out.length);
+        assertEquals("Hello", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("' Hello '", ',', false);
+        assertEquals(1, out.length);
+        assertEquals(" Hello ", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("'Hello', 'World'", ',', true);
+        assertEquals(2, out.length);
+        assertEquals("Hello", out[0]);
+        assertEquals("World", out[1]);
+
+        out = StringQuoteHelper.splitSafeQuote("\"Hello\"", ',', true);
+        assertEquals(1, out.length);
+        assertEquals("Hello", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("\" Hello \"", ',', true);
+        assertEquals(1, out.length);
+        assertEquals("Hello", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("\" Hello \"", ',', false);
+        assertEquals(1, out.length);
+        assertEquals(" Hello ", out[0]);
+
+        out = StringQuoteHelper.splitSafeQuote("\"Hello\", \"World\"", ',', 
true);
+        assertEquals(2, out.length);
+        assertEquals("Hello", out[0]);
+        assertEquals("World", out[1]);
     }
 
     @Test
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 5f993d8b7d8..53ba874bb23 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -1226,7 +1226,7 @@ public final class PropertyBindingSupport {
      */
     public static Object newInstanceConstructorParameters(CamelContext 
camelContext, Class<?> type, String parameters)
             throws Exception {
-        String[] params = StringQuoteHelper.splitSafeQuote(parameters, ',');
+        String[] params = StringQuoteHelper.splitSafeQuote(parameters, ',', 
false);
         Constructor found = findMatchingConstructor(type.getConstructors(), 
params);
         if (found != null) {
             Object[] arr = new Object[found.getParameterCount()];
@@ -1324,7 +1324,7 @@ public final class PropertyBindingSupport {
     public static Object newInstanceFactoryParameters(
             CamelContext camelContext, Class<?> type, String factoryMethod, 
String parameters)
             throws Exception {
-        String[] params = StringQuoteHelper.splitSafeQuote(parameters, ',');
+        String[] params = StringQuoteHelper.splitSafeQuote(parameters, ',', 
false);
         Method found = findMatchingFactoryMethod(type.getMethods(), 
factoryMethod, params);
         if (found != null) {
             Object[] arr = new Object[found.getParameterCount()];

Reply via email to