davsclaus opened a new pull request, #31087:
URL: https://github.com/apache/camel/pull/31087
_Claude Code on behalf of Claus Ibsen_
Follow-up to CAMEL-27234 (#30873), which is not released yet.
## Problem
Since CAMEL-27234, `HttpComponent.createProducer` (the rest producer factory
used by `rest` and `rest-openapi`) writes the options of the producer, such as
the login options of a `rest-openapi` endpoint, into the http endpoint URI.
`URISupport.createQueryString` percent-encodes them. `getEndpoint` then
normalizes the URI, and normalizing decodes `%26`:
```
normalizeUri("http://localhost:1/x?authPassword=p%26ss%2Bword")
-> http://localhost:1/x?authPassword=p&ss+word=
```
The endpoint still gets the right password from the parameters map. But the
URI now has an unknown option `ss+word=`, and the http producer sends unknown
options as query parameters. So **part of the password goes into the request
URL**.
Found by
`HttpKameletsTargetTest.restOpenApiSinkLogsInWithBasicWhenTheServiceAsks` in
camel-kamelets. It sets `authPassword=RAW(p&ss+word)` on `rest-openapi-sink`,
and the request now has `?ss+word=`.
## Fix
Text values are written into the URI as `RAW(...)`, or `RAW{...}` when the
value has a `)`. Values that are already RAW are kept as they are. The
parameters map still takes precedence over the URI values
(`DefaultComponent.createEndpoint`), so the endpoint gets the same values as
before. Only the URI changes, and with it which endpoint is cached.
## Tests
- `HttpRestProducerParametersTest`: two new tests, with the passwords
`p&ss+word` and `p)&s{s}+(w%26rd`. They check the Basic login and that the
request has no query string. Both fail without the fix.
- `camel-http`: 329 tests + 9 ITs pass. `camel-rest-openapi`: 248 tests pass.
## Not changed
`URISupport.normalizeUri` decoding `%26` into a separate option looks wrong
in its own right. `URISupportTest` has no case for it. It is left for a
separate ticket.
🤖 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]