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

   # Description
   
   [CAMEL-25635](https://issues.apache.org/jira/browse/CAMEL-25635)
   
   `VertxPlatformHttpConsumer.processHttpRequest` read the request charset with 
`ctx.parsedHeaders().contentType().parameter("charset")`. Vert.x looks the 
parameter name up as written, so `Content-Type: text/plain; Charset=ISO-8859-1` 
gave no charset: `CamelCharsetName` and `CamelHttpCharacterEncoding` were not 
set and the body was converted to a String as UTF-8. Parameter names are 
case-insensitive (RFC 9110, 5.6.6). The same defect was fixed for 
camel-undertow (CAMEL-25295, `UndertowHelper.getCharsetFromContentType`) and 
camel-netty-http (CAMEL-25305); camel-servlet and camel-jetty read `Charset=` 
through the servlet container (differential test with the same request to each 
consumer).
   
   The parameter is now looked up in `contentType().parameters()` ignoring the 
case of its name (new private helper `charsetParameter`).
   
   The helper also handles an empty value. Vert.x returns `""` for `charset=`, 
`charset=""` and `charset=; format=flowed`; the consumer then set 
`CamelCharsetName` to `""` and converting the body to a String failed in 
`Charset.forName("")` (`IllegalCharsetNameException`, HTTP 500). CAMEL-25355 
fixed exactly this case in camel-util, camel-support and camel-http-common, but 
not here. The value is now normalized with `IOHelper.normalizeCharset` and an 
empty result counts as no charset, as 
`UndertowHelper.getCharsetFromContentType` and 
`NettyHttpHelper.getCharsetFromContentType` do on main.
   
   What changes for users (4.24 upgrade guide entry): a body with `Charset=` in 
another case 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.
   
   Tests:
   - New `VertxPlatformHttpRequestCharsetTest` (3 tests, the route converts the 
body to a String and answers in UTF-8), all three fail on main:
     - an ISO-8859-1 body with `Charset=ISO-8859-1`: `array lengths differ, 
expected: <17> but was: <20>` (each of ü, ß, ö decoded as the replacement 
character);
     - a UTF-8 body with `charset=`, and with `charset=""; format=flowed`: 
`expected: <200> but was: <500>` (`IllegalCharsetNameException` in the type 
conversion).
     The lower-case spelling is covered by the existing 
`VertxPlatformHttpResponseCharsetTest.testEchoInRequestCharset`.
   - camel-platform-http-vertx with the change (built with `-am`, all 40 test 
classes): 159 tests, 0 failures, 1 skipped.
   
   Not changed: `HttpUtil.getCharsetFromContentType` in camel-support (used by 
the camel-http producer for the response charset and by `CamelServlet`) still 
looks for `charset=` in lower case; that is a separate follow-up.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
     (The ticket is drafted and not filed yet; CAMEL-25635 is a placeholder 
until it is.)
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested camel-platform-http-vertx, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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