camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1166956 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
Date Fri, 09 Sep 2011 01:56:33 GMT
Author: hadrian
Date: Fri Sep  9 01:56:33 2011
New Revision: 1166956

URL: http://svn.apache.org/viewvc?rev=1166956&view=rev
Log:
CAMEL-4405. Provide a properly encoded URI to all components

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
    camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.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=1166956&r1=1166955&r2=1166956&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 Fri Sep
 9 01:56:33 2011
@@ -82,12 +82,12 @@ public abstract class DefaultComponent e
         }
         Map<String, Object> parameters = URISupport.parseParameters(u);
 
-        validateURI(uri, path, parameters);
+        validateURI(encodedUri, path, parameters);
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Creating endpoint uri=[{}], path=[{}], parameters=[{}]", new Object[]{uri,
path, parameters});
+            LOG.debug("Creating endpoint uri=[{}], path=[{}], parameters=[{}]", new Object[]{encodedUri,
path, parameters});
         }
-        Endpoint endpoint = createEndpoint(uri, path, parameters);
+        Endpoint endpoint = createEndpoint(encodedUri, path, parameters);
         if (endpoint == null) {
             return null;
         }

Modified: camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java?rev=1166956&r1=1166955&r2=1166956&view=diff
==============================================================================
--- camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
(original)
+++ camel/trunk/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
Fri Sep  9 01:56:33 2011
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.component.irc;
 
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Dictionary;
@@ -99,7 +101,7 @@ public class IrcConfiguration implements
         return retval.trim();
     }
 
-    public void configure(String uriStr) throws URISyntaxException {
+    public void configure(String uriStr) throws URISyntaxException, UnsupportedEncodingException
 {
         // fix provided URI and handle that we can use # to indicate the IRC room
         if (uriStr.startsWith("ircs")) {
             setUsingSSL(true);
@@ -121,9 +123,15 @@ public class IrcConfiguration implements
         setRealname(uri.getUserInfo());
         setHostname(uri.getHost());
 
-        if (uri.getFragment() != null && uri.getFragment().length() != 0) {
-            String channel = "#" + uri.getFragment();
-            addChannel(channel);
+        String path = uri.getPath();
+        if (path != null) {
+            path = URLDecoder.decode(path, "UTF-8");
+            if (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            if (path.startsWith("#")) {
+                addChannel(path);
+            } // else should probably issue a warning?
         }
     }
 



Mime
View raw message