davsclaus opened a new pull request, #30688:
URL: https://github.com/apache/camel/pull/30688

   _Claude Code on behalf of davsclaus_
   
   [CAMEL-27482](https://issues.apache.org/jira/browse/CAMEL-27482)
   
   ### Problem
   
   For a WebSocket client (`consumeAsClient`, or a producer to a remote 
server), the query of the endpoint URI reached the server decoded. A `RAW()` 
value didn't help either:
   
   ```
   
vertx-websocket:localhost:8080/path?consumeAsClient=true&token=RAW(a+b)&sig=RAW(x&y=z)
     -> GET /path?sig=x&y=z&token=a+b      (the server reads token="a b", and 
sig is split)
   ```
   
   Two places:
   - `VertxWebsocketEndpoint.getWebSocketConnectOptions` built the request URI 
with `URISupport.pathAndQueryOf`, which uses the decoded 
`getPath()`/`getQuery()`. The URI itself held the right raw query 
(`token=a%2Bb&sig=x%26y%3Dz`).
   - When the component filled in a default host, port or path, it rebuilt the 
URI with the multi-argument `URI` constructor from `getQuery()`, which decodes 
it too.
   
   Found while writing the websocket-source Kamelet 
(apache/camel-kamelets#3379). Tokens and signatures in the URL break.
   
   ### Change
   
   - The request URI is the raw path and query of the URI (`rawPathAndQuery`).
   - The default host/port/path branch keeps the raw query 
(`URISupport.createURIWithQuery`).
   - Docs: a value with `+`, `&` or `%` must be written as a raw value.
   
   Not changed: a plain `%2B` or `%26` in an endpoint URI (without `RAW()`) is 
decoded by Camel's endpoint URI normalization before any component reads it 
(`p=a%2Bb&t=x%26y` becomes `p=a b`, `t=x`, `y=`). That is the same for every 
component, and `RAW()` is the documented way around it.
   
   ### Tests
   
   - `VertxWebsocketClientRawQueryTest`: a plain Vert.x server records the 
query of each handshake. A client consumer, and a producer whose URI has no 
path (the default branch), send `token=RAW(a+b)&sig=RAW(x&y=z)&text=RAW(a b)`. 
The server decodes `a+b`, `x&y=z` and `a b`. On the original code, both tests 
fail (`token` arrives as `a b`).
   - All 124 tests of camel-vertx-websocket pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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