Author: ron.sigal(a)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();
+ }
}
Show replies by date