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


##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java:
##########
@@ -849,6 +849,27 @@ private static boolean isUriValue(Object value) {
                 || value instanceof Character || value instanceof Enum<?>;
     }
 
+    /**
+     * The value as written in the endpoint uri. Text is written as a RAW 
value, as a percent-encoded value is decoded
+     * when the uri is normalized: an & or + in a password would then split 
the option into another option, which the
+     * producer sends as a query parameter. The endpoint still gets the value 
as given, as the parameters take
+     * precedence over the uri.
+     */
+    private static Object asUriValue(Object value) {
+        if (!(value instanceof CharSequence) && !(value instanceof Character)) 
{
+            return value;
+        }
+        String text = value.toString();
+        for (char start : URISupport.RAW_TOKEN_START) {
+            if (text.startsWith(URISupport.RAW_TOKEN_PREFIX + start)) {
+                return text;
+            }
+        }
+        // RAW{...} when the value has a ) so it cannot end the RAW value too 
early
+        int kind = text.indexOf(URISupport.RAW_TOKEN_END[0]) >= 0 ? 1 : 0;
+        return URISupport.RAW_TOKEN_PREFIX + URISupport.RAW_TOKEN_START[kind] 
+ text + URISupport.RAW_TOKEN_END[kind];

Review Comment:
   Thanks. Looking into it showed that the choice itself was too strict: a RAW 
value only ends at a closing bracket followed by `&` (or the end), so a `)` 
alone never ends `RAW(...)`. Picking `RAW{...}` for any `)` broke a value such 
as `p}&ss)w+rd)`, whose rest was then sent as a query parameter.
   
   Fixed in fba14e56b5de: `RAW{...}` is used only when the value has a `)&`. A 
new test covers `p}&ss)w+rd)`, and it fails with the old choice.
   
   I did not take the suggested comment as written: a value with both `)&` and 
`}&` still has its URI split, so the endpoint gets the right value from the 
parameters, but the rest of the value is still sent as a query parameter. The 
code comment now says that.
   
   _Claude Code on behalf of davsclaus_
   



-- 
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