[
https://issues.apache.org/jira/browse/CAMEL-25635?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-25635.
---------------------------------
Resolution: Fixed
> camel-platform-http-vertx - the request charset parameter is only recognized
> in lower case (Charset=ISO-8859-1 is decoded as UTF-8), and an empty charset=
> fails the request with 500
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25635
> URL: https://issues.apache.org/jira/browse/CAMEL-25635
> Project: Camel
> Issue Type: Bug
> Components: camel-platform-http-vertx
> Reporter: shashank
> Assignee: shashank
> Priority: Major
> Fix For: 4.24.0
>
>
> {{VertxPlatformHttpConsumer.processHttpRequest}} reads the request charset
> with (line 494 at main 1de5ec5135f8)
> {code:java}
> final String charset = ctx.parsedHeaders().contentType().parameter("charset");
> {code}
> Vert.x {{ParsedHeaderValue.parameter}} looks the name up as it is written, so
> {{Content-Type: text/plain; Charset=ISO-8859-1}} gives no charset:
> {{CamelCharsetName}} and {{CamelHttpCharacterEncoding}} are not set and the
> body is converted to a String as UTF-8 ({{café}} becomes {{caf�}}). Parameter
> names are case-insensitive (RFC 9110, 5.6.6). camel-undertow (CAMEL-25295,
> {{UndertowHelper.getCharsetFromContentType}}), camel-netty-http (CAMEL-25305)
> and camel-servlet / camel-jetty (the servlet container) read {{Charset=}}, as
> the differential test of the five consumers with the same request shows.
> The same line does not handle an empty value: Vert.x returns {{""}} for
> {{charset=}}, {{charset=""}} and {{charset=; format=flowed}}, the consumer
> sets {{CamelCharsetName}} to {{""}}, and converting the body to a String
> fails in {{Charset.forName("")}} ({{IllegalCharsetNameException}}, the client
> gets HTTP 500). CAMEL-25355 fixed exactly this case in camel-util,
> camel-support and camel-http-common, but not in this consumer;
> {{UndertowHelper.getCharsetFromContentType}} and
> {{NettyHttpHelper.getCharsetFromContentType}} already return null for an
> empty value.
> h3. Reproduction
> New {{VertxPlatformHttpRequestCharsetTest}}: a route converts the body to a
> String and answers in UTF-8. With main, {{Charset=ISO-8859-1}}: {{array
> lengths differ, expected: <17> but was: <20>}} (each of ü, ß, ö came back as
> the 3-byte UTF-8 replacement character); {{charset=}} and {{charset="";
> format=flowed}}: {{expected: <200> but was: <500>}}. An enumeration of the
> 128 spellings of the parameter name: main recognizes 1, the fix all.
> camel-platform-http-vertx with the fix: 159 tests, 0 failures, 1 skipped.
> h3. Proposed fix
> Look the parameter up in {{contentType().parameters()}} ignoring the case of
> its name, normalize the value with {{IOHelper.normalizeCharset}} and treat an
> empty result as no charset.
> Behaviour change (4.24 upgrade-guide entry): such a body is decoded in its
> declared charset and {{CamelCharsetName}} is set; a request with an empty
> charset parameter is decoded with the default charset instead of failing with
> 500.
> Affected: main 1de5ec5135f8 (tested). camel-4.23.x, camel-4.22.1,
> camel-4.18.4 and camel-4.14.9 have the same line: read, not run.
> Not in scope: {{HttpUtil.getCharsetFromContentType}} in camel-support still
> looks for {{charset=}} in lower case (callers: the camel-http producer for
> the response charset, {{CamelServlet}}).
> Duplicate check (2026-10-14): JIRA text "platform-http charset case",
> "platform-http Charset": only the three linked tickets (other components /
> the response side).
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)