Author: hadrian Date: Fri Feb 3 14:23:22 2012 New Revision: 1240187 URL: http://svn.apache.org/viewvc?rev=1240187&view=rev Log: CAMEL-4954. Fix for double decoding of % in uris
Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/URISupport.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/URISupport.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/URISupport.java?rev=1240187&r1=1240186&r2=1240187&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/URISupport.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/URISupport.java Fri Feb 3 14:23:22 2012 @@ -83,8 +83,10 @@ public final class URISupport { for (String parameter : parameters) { int p = parameter.indexOf("="); if (p >= 0) { + // The replaceAll is an ugly workaround for CAMEL-4954, awaiting a cleaner fix once CAMEL-4425 + // is fully resolved in all components String name = URLDecoder.decode(parameter.substring(0, p), CHARSET); - String value = URLDecoder.decode(parameter.substring(p + 1), CHARSET); + String value = URLDecoder.decode(parameter.substring(p + 1).replaceAll("%", "%25"), CHARSET); // does the key already exist? if (rc.containsKey(name)) { Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java?rev=1240187&r1=1240186&r2=1240187&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java Fri Feb 3 14:23:22 2012 @@ -126,6 +126,13 @@ public class URISupportTest extends Cont assertEquals("jms://queue:foo?foo=bar&selector=somekey%3D%27somevalue%27", out); } + public void testNormalizeEndpointWithPercentSignInParameter() throws Exception { + String out = URISupport.normalizeUri("http://someendpoint?username=james&password=%25test"); + assertNotNull(out); + // Camel will safe encode the URI + assertEquals("http://someendpoint?password=%25test&username=james", out); + } + public void testParseParameters() throws Exception { URI u = new URI("quartz:myGroup/myTimerName?cron=0+0+*+*+*+?"); Map<String, Object> params = URISupport.parseParameters(u);