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 2016/12/08 14:12:49 UTC

[16/16] camel git commit: Camel catalog - Should ignore validating uri parameters where the key is a placeholder and therefore not a known key name.

Camel catalog - Should ignore validating uri parameters where the key is a placeholder and therefore not a known key name.


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

Branch: refs/heads/camel-2.18.x
Commit: 2e2a49eb32f51e794f9fd70bbd3d1705ac49ede2
Parents: dc7ed4d
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Dec 8 15:03:22 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Dec 8 15:12:24 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/catalog/URISupport.java     | 14 ++++++++++++--
 .../org/apache/camel/catalog/CamelCatalogTest.java    | 12 ++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2e2a49eb/platforms/catalog/src/main/java/org/apache/camel/catalog/URISupport.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/URISupport.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/URISupport.java
index 079426a..f61f0c0 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/URISupport.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/URISupport.java
@@ -230,7 +230,12 @@ public final class URISupport {
                 // the & denote parameter is ended
                 if (ch == '&') {
                     // parameter is ended, as we hit & separator
-                    addParameter(key.toString(), value.toString(), rc, useRaw || isRaw);
+                    String aKey = key.toString();
+                    // the key may be a placeholder of options which we then do not know what is
+                    boolean validKey = !aKey.startsWith("{{") && !aKey.endsWith("}}");
+                    if (validKey) {
+                        addParameter(aKey, value.toString(), rc, useRaw || isRaw);
+                    }
                     key.setLength(0);
                     value.setLength(0);
                     isKey = true;
@@ -249,7 +254,12 @@ public final class URISupport {
 
             // any left over parameters, then add that
             if (key.length() > 0) {
-                addParameter(key.toString(), value.toString(), rc, useRaw || isRaw);
+                String aKey = key.toString();
+                // the key may be a placeholder of options which we then do not know what is
+                boolean validKey = !aKey.startsWith("{{") && !aKey.endsWith("}}");
+                if (validKey) {
+                    addParameter(aKey, value.toString(), rc, useRaw || isRaw);
+                }
             }
 
             return rc;

http://git-wip-us.apache.org/repos/asf/camel/blob/2e2a49eb/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 271ca3f..85a6076 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -866,4 +866,16 @@ public class CamelCatalogTest {
         assertTrue(doc.contains("JSonPath language"));
     }
 
+    @Test
+    public void testValidateEndpointTwitterSpecial() throws Exception {
+        String uri = "twitter://search?{{%s}}&keywords=java";
+
+        EndpointValidationResult result = catalog.validateEndpointProperties(uri);
+        assertTrue(result.isSuccess());
+
+        uri = "twitter://search?{{%s}}";
+        result = catalog.validateEndpointProperties(uri);
+        assertTrue(result.isSuccess());
+    }
+
 }