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

   # Description
   
   [CAMEL-25295](https://issues.apache.org/jira/browse/CAMEL-25295)
   
   Follow-up of #27245 (CAMEL-25248), as suggested in its review.
   
   camel-undertow found the charset of a `Content-Type` with Undertow's 
`Headers.extractQuotedValueFromHeader(contentType, "charset")`, which matches 
the parameter name case-sensitively, while parameter names are case-insensitive 
(RFC 9110). With `Content-Type: text/plain; Charset=ISO-8859-1`:
   - the consumer did not set `CamelCharsetName`, so the request body was read 
as UTF-8;
   - a `String` body of the consumer response or the producer request was 
written as UTF-8 while the header declared ISO-8859-1.
   
   This change adds `UndertowHelper.getCharsetFromContentType`, which finds the 
`charset` parameter case-insensitively, as 
`IOHelper.getCharsetNameFromContentType` does for the other HTTP components 
(camel-http-base `HttpHelper`, camel-http, camel-jetty, camel-vertx-http), and 
uses it for both the request charset and `UndertowHelper.toByteBuffer`. It 
deliberately does not use `IOHelper.getCharsetNameFromContentType` itself, 
which returns UTF-8 when there is no charset: the consumer sets 
`CamelCharsetName` only for a declared charset (892be63447, as the 
camel-platform-http-vertx consumer does), and a `String` body without a charset 
is converted as before. The upgrade guide gets a `====` subsection under the 
camel-undertow entry of CAMEL-25248.
   
   Tests:
   - `UndertowStringBodyCharsetTest`: three new tests with 
`Charset=ISO-8859-1`, for the consumer response, the consumer request, and the 
producer request, and one for a request without a charset (no 
`CamelCharsetName` / `CamelHttpCharacterEncoding`; it fails with `expected: 
<null> but was: <UTF-8>` if `IOHelper.getCharsetNameFromContentType` is used).
   - Without the change all three fail (`array lengths differ, expected: <14> 
but was: <17>`, and `<17>` / `<20>` for the request read as UTF-8).
   - With the change all camel-undertow tests pass: 200 tests, 0 failures, 1 
skipped.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] 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).
   
   # 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 the affected module, 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