diff --git a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java index 25250ff857b6b..004425829f160 100644 --- a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java +++ b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java @@ -900,6 +900,12 @@ private static String buildReorderingParameters(String scheme, String path, Stri // createQueryString()/URLEncoder, which would needlessly percent-encode characters that are // legal unescaped in a URI query, such as ':' (eg host:port) or '/' (eg produces=application/json) query = buildSafeQueryString(keys, parameters); + if (query.indexOf('%') != -1) { + // a key or value needed a percent escape (such as = or # in a value), and a uri with % is normalized by + // the complex normalizer, which form-encodes the whole query; encode the same way here so normalizing a + // normalized uri gives the same uri (the fast parser only takes uris without %, so all % come from here) + query = createQueryString(keys, parameters, true); + } return buildUri(scheme, path, query); } @@ -939,7 +945,7 @@ private static String buildSafeQueryString(String[] sortedKeys, Map