[jboss-svn-commits] JBL Code SVN: r38128 - labs/jbossesb/branches/JBESB_4_11_CP/product/rosetta/src/org/jboss/internal/soa/esb/publish.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jun 28 22:23:37 EDT 2012
Author: tcunning
Date: 2012-06-28 22:23:36 -0400 (Thu, 28 Jun 2012)
New Revision: 38128
Modified:
labs/jbossesb/branches/JBESB_4_11_CP/product/rosetta/src/org/jboss/internal/soa/esb/publish/AbstractContractReferencePublisher.java
Log:
JBESB-3804
Encode unsafe URI characters before creating URIs.
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/rosetta/src/org/jboss/internal/soa/esb/publish/AbstractContractReferencePublisher.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/rosetta/src/org/jboss/internal/soa/esb/publish/AbstractContractReferencePublisher.java 2012-06-28 01:29:23 UTC (rev 38127)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/rosetta/src/org/jboss/internal/soa/esb/publish/AbstractContractReferencePublisher.java 2012-06-29 02:23:36 UTC (rev 38128)
@@ -21,7 +21,6 @@
import java.net.URI;
import java.net.URISyntaxException;
-
import org.jboss.soa.esb.Service;
/**
@@ -35,12 +34,40 @@
private final Service service;
private final String description;
+ private static final char[] UNSAFE_CHARS = { '%', ' ', '\"', '#', '<', '>',
+ '[', '\\', ']', '^', '`', '{', '|', '}', '~' };
+
public AbstractContractReferencePublisher(Service service, String description)
{
this.service = service;
this.description = description;
}
+ /**
+ * Encode unsafe URI characters
+ * @param unencodedStr un-encoded string
+ * @return encoded string
+ */
+ public String encode(String unencodedStr) {
+ String result = unencodedStr;
+
+ for (char c : UNSAFE_CHARS) {
+ char [] chars = new char[1]; //convert string to individual chars
+ chars[0] = c;
+
+ String bin = new String();
+ for(int j=0; j<chars.length; j++) {
+ bin += "%" + Integer.toHexString(chars[j]); //convert char to hex value
+ }
+
+
+ result = result.replace((new Character(c)).toString(), bin);
+ }
+
+ return result;
+ }
+
+
public final Service getService()
{
return service;
@@ -56,14 +83,16 @@
String endpointAddress = getEndpointAddress();
if (endpointAddress != null)
{
+ URI uri = null;
try
{
- return new URI(endpointAddress);
+ uri = new URI(encode(endpointAddress));
}
catch (URISyntaxException use)
{
- // fall through
- }
+ use.printStackTrace();
+ }
+ return uri;
}
return null;
}
@@ -73,14 +102,16 @@
String endpointAddress = getEndpointAddress();
if (endpointAddress != null)
{
+ URI uri = null;
try
{
- return new URI(endpointAddress + "?wsdl");
+ uri = new URI(encode(endpointAddress) + "?wsdl");
}
catch (URISyntaxException use)
{
- // fall through
- }
+ use.printStackTrace();
+ }
+ return uri;
}
return null;
}
More information about the jboss-svn-commits
mailing list