This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch quick-fix/http-rest-producer-raw-options in repository https://gitbox.apache.org/repos/asf/camel.git
commit fba14e56b5dea6fdcc811862a5864c5fb1159b88 Author: Claus Ibsen <[email protected]> AuthorDate: Sun Nov 29 10:14:07 2026 +0100 chore: camel-http - write a rest producer option as RAW{...} only when it has a )& A RAW value ends at the first closing bracket followed by &, so a ) alone does not end RAW(...). Choosing RAW{...} for any ) broke a value with a }& and a ), such as p}&ss)w+rd), whose rest was sent as a query parameter. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../main/java/org/apache/camel/component/http/HttpComponent.java | 6 ++++-- .../camel/component/http/HttpRestProducerParametersTest.java | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java index 46897617cba1..87e090228b2d 100644 --- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java +++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java @@ -865,8 +865,10 @@ public class HttpComponent extends HttpCommonComponent implements RestProducerFa 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; + // a RAW value ends at the first closing bracket followed by &, so use RAW{...} when the value has a )&. + // A value with both a )& and a }& cannot be written as RAW: its uri is split, and the producer sends the + // rest of the value as a query parameter (the endpoint still gets the value from the parameters) + int kind = text.contains(URISupport.RAW_TOKEN_END[0] + "&") ? 1 : 0; return URISupport.RAW_TOKEN_PREFIX + URISupport.RAW_TOKEN_START[kind] + text + URISupport.RAW_TOKEN_END[kind]; } diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRestProducerParametersTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRestProducerParametersTest.java index d7a22f875079..ac45e70c9900 100644 --- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRestProducerParametersTest.java +++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRestProducerParametersTest.java @@ -97,6 +97,15 @@ public class HttpRestProducerParametersTest { assertThat(query.get()).isNull(); } + @Test + public void shouldNotSendPartOfThePasswordWithClosingBracketsAsQueryParameter() throws Exception { + Producer basic = createProducer(Map.of("authMethod", "Basic", "authUsername", "ann", "authPassword", "p}&ss)w+rd)", + "authenticationPreemptive", "true")); + + assertThat(send(basic)).isEqualTo(basic("ann", "p}&ss)w+rd)")); + assertThat(query.get()).isNull(); + } + private static String basic(String user, String password) { return "Basic " + Base64.getEncoder().encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8)); }
