allthingssecurity opened a new pull request, #27851: URL: https://github.com/apache/camel/pull/27851
# Description [CAMEL-25633](https://issues.apache.org/jira/browse/CAMEL-25633) `UndertowConsumer` parses form requests with `new EagerFormParsingHandler()`. That uses Undertow's default `FormParserFactory`, whose form-urlencoded and multipart parsers fall back to ISO-8859-1 when the request declares no charset. Browsers send form fields as UTF-8 and do not declare a charset, so every non-ASCII field was corrupted with default options: `name=Gr%C3%BC%C3%9Fe` arrived as `GrüÃ\u009fe` in the `name` header and in the body map, and the same for a text field of a multipart form. The handler is now created with `FormParserFactory.builder().withDefaultCharset("UTF-8").build()` (`build()` sets the default encoding of each parser, Undertow 2.4.4.Final as in `parent/pom.xml` on main). A charset that the request or a multipart part declares is still used. This completes #22471 (merged 2026-04-08), which fixed the same Undertow ISO-8859-1 default for the request body ("matching the behavior of `DefaultHttpBinding`"): since then the consumer sets the exchange charset only when the request declares one. The form path, where Undertow's form parsers decode the fields themselves, was not covered by that change. How the siblings decode the same requests (read on main, and sent to each consumer in a differential test): - camel-platform-http-vertx (Vert.x): UTF-8. - camel-servlet / camel-jetty, form-urlencoded body: `DefaultHttpBinding.readFormUrlEncodedBody` decodes with `request.getCharacterEncoding()` and falls back to UTF-8 when that is null, which it is for a request without a charset unless the container is configured with a default request encoding. - camel-servlet / camel-jetty, multipart text fields: taken from the servlet container's parameters (`populateRequestParameters`, `request.getParameterValues`), so the container's default applies. Jetty 12 decodes them as UTF-8 (what the differential test ran); Tomcat uses ISO-8859-1 unless `request-character-encoding` is set (Spring Boot sets UTF-8 by default). So camel-servlet agrees with this change only when hosted in Jetty, or in a Tomcat with a UTF-8 request encoding. - camel-netty-http does not percent-decode form values unless `urlDecodeHeaders=true`, a separate option. What changes for users (4.24 upgrade guide entry): non-ASCII form fields without a declared charset are decoded as UTF-8. A client that sends ISO-8859-1 form data without declaring it gets replacement characters now; it has to declare the charset, which is then used. Tests: - New `UndertowFormCharsetTest` (4 tests): - a form-urlencoded and a multipart request with `name=Grüße` in UTF-8 and no charset; the header and the body map have `Grüße`. On main both fail with `expected: <Grüße> but was: <GrüÃe>`; - the caveat of the change: `name=Gr%FC%DFe` (ISO-8859-1, no charset) now gives `Gr\uFFFD\uFFFDe`. On main it gives `Grüße`, so it fails there; it pins the behaviour stated in the upgrade guide; - `charset=ISO-8859-1` with ISO-8859-1 bytes: passes on main too and is there because the change touches the charset choice of the parsers (a declared charset must still win). - camel-undertow with the change: 228 tests, 0 failures, 1 skipped. What was not run: the modules that use camel-undertow as a test server (for example camel-vertx-http) were not run with this change. # 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-25633 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-undertow, 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]
