davsclaus commented on code in PR #27131:
URL: https://github.com/apache/camel/pull/27131#discussion_r4155930749


##########
core/camel-util/src/main/java/org/apache/camel/util/URISupport.java:
##########
@@ -955,6 +955,9 @@ private static void appendSafeQueryStringParameter(String 
key, String value, Str
             // characters in a URI query per RFC 3986 - 
UnsafeUriCharactersEncoder does not escape them
             // as it is also used outside of this query-value context
             String encoded = 
UnsafeUriCharactersEncoder.encode(value).replace("&", "%26").replace("=", 
"%3D");
+            // a space as +, as the complex normalizer (createQueryString) 
writes it, so normalizing a normalized
+            // uri gives the same uri; the fast parser only takes uris without 
%, so %20 here is always a space
+            encoded = encoded.replace("%20", "+");

Review Comment:
   _Claude Code on behalf of davsclaus_
   
   Thanks, good catch. Fixed in this PR (9a2e5da551bd) instead of a follow-up.
   
   When a key or value needs a percent escape (`=` or `#` in a value), the fast 
path now form-encodes the whole query, as the complex path does, so the second 
normalization gives the same string. Without such an escape the query keeps the 
readable form from CAMEL-24524 (`produces=application/json`, `localhost:19092`).
   
   Your examples, once and twice:
   
   ```
   jms:queue:foo?selector=somekey='somevalue'&foo=bar   -> 
jms://queue:foo?foo=bar&selector=somekey%3D%27somevalue%27
   log:foo?secretKey=abc/def==                          -> 
log://foo?secretKey=abc%2Fdef%3D%3D
   log:foo?url=https://example.com/hook?token=abc       -> 
log://foo?url=https%3A%2F%2Fexample.com%2Fhook%3Ftoken%3Dabc
   log:foo?marker=a#b/c                                 -> 
log://foo?marker=a%23b%2Fc
   ```
   
   I added them to `testNormalizeTwiceGivesTheSameUri`. 
`testNormalizeEndpointWithEqualSignInParameter` is back to the 4.22.1 value 
(`somekey%3D%27somevalue%27`). Compared with 4.22.1, the output only differs 
where 4.22.1 itself depended on the key order. The code comment now only claims 
what holds, and the CAMEL-24524 note in the 4.23 upgrade guide says when the 
query is form-encoded.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to