[jboss-remoting-commits] JBoss Remoting SVN: r4310 - remoting2/branches/2.2/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Sun Jun 22 02:02:19 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-06-22 02:02:19 -0400 (Sun, 22 Jun 2008)
New Revision: 4310

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java
Log:
JBREM-1003: Added code to encode and decode "%" character.

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java	2008-06-22 05:55:53 UTC (rev 4309)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/InvokerLocator.java	2008-06-22 06:02:19 UTC (rev 4310)
@@ -306,12 +306,12 @@
    {
       try
       {
-         URI uri = new URI(uriString);
+         URI uri = new URI(encodePercent(uriString));
          protocol = uri.getScheme();
-         host = resolveHost(uri.getHost());
+         host = decodePercent(resolveHost(uri.getHost()));
          port = uri.getPort();
          path = uri.getPath();
-         query = uri.getQuery();
+         query = decodePercent(uri.getQuery());
       }
       catch (URISyntaxException e)
       {
@@ -581,5 +581,34 @@
       return serializationTypeLocal;
    }
 
-
+   protected static String encodePercent(String s)
+   {
+      if (s == null) return null;
+      StringTokenizer st = new StringTokenizer(s, "%");
+      StringBuffer sb = new StringBuffer();
+      int limit = st.countTokens() - 1;
+      for (int i = 0; i < limit; i++)
+      {
+         String token = st.nextToken();
+         sb.append(token).append("%25");
+      }
+      sb.append(st.nextToken());
+      return sb.toString();
+   }
+   
+   protected static String decodePercent(String s)
+   {
+      if (s == null) return null;
+      StringBuffer sb = new StringBuffer();
+      int fromIndex = 0;
+      int index = s.indexOf("%25", fromIndex);
+      while (index >= 0)
+      {
+         sb.append(s.substring(fromIndex, index)).append('%');
+         fromIndex = index + 3;
+         index = s.indexOf("%25", fromIndex);
+      }
+      sb.append(s.substring(fromIndex));
+      return sb.toString();
+   }
 }




More information about the jboss-remoting-commits mailing list