gnodet-bot commented on code in PR #31087:
URL: https://github.com/apache/camel/pull/31087#discussion_r4730767309
##########
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:
💡 **Nit (low):** The choice between `RAW(...)` and `RAW{...}` is based on
whether the value contains a `)` character. If a value contained both `)` and
the literal sequence `}&` (causing `rawValueEnd` to terminate early at the
embedded `}`), neither form would survive normalisation correctly. This is an
inherent limitation of the RAW encoding scheme, not introduced by this PR, and
covered by the parameters-map precedence safety net. A brief comment here
noting the assumption would help future maintainers:
```suggestion
// If text contains ')' use RAW{...} form; if it contains both ')'
and '}' followed
// by '&', neither form is fully safe — but the parameters map takes
precedence over
// the URI, so the endpoint always receives the correct value
regardless.
int kind = text.indexOf(URISupport.RAW_TOKEN_END[0]) >= 0 ? 1 : 0;
```
--
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]