Repository navigation
fix(serialization): support content-type parameters and case-insensitivity in form factories - #2239
Open
Hardik K (hardikkaurani) wants to merge 2 commits into
Conversation
…ivity in form factories FormParseNodeFactory and FormSerializationWriterFactory previously checked content types with strict string equality against application/x-www-form-urlencoded. As a result, content types with MIME parameters (such as charset=utf-8) or case variations (such as APPLICATION/X-WWW-FORM-URLENCODED) were rejected with IllegalArgumentException. Strip MIME parameters and compare against the valid content type case-insensitively, aligning with RFC 2045 §5.1 and matching TextParseNodeFactory and MultipartSerializationWriterFactory. Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…E parameters and case variants Add parameterized tests in ParseNodeFactoryTests and SerializationWriterFactoryTests asserting that FormParseNodeFactory and FormSerializationWriterFactory properly accept content types with MIME parameters (such as charset=utf-8), uppercase, and mixed-case variants, while continuing to reject delimiter-only and invalid media types. Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Contributor
Author
|
Hi Vincent Biret (@baywet), following up on the changes introduced in #2236 and #2229, This PR brings the form serialization factories to parity by stripping MIME parameters (such as |
Contributor
Author
|
Thanks Vincent Biret (@baywet) |
Vincent Biret (baywet)
approved these changes
Nov 9, 2026
Vincent Biret (baywet)
enabled auto-merge
November 9, 2026 20:09
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FormParseNodeFactory.getParseNode()andFormSerializationWriterFactory.getSerializationWriter()used strict string equality (!contentType.equals(validContentType)) to validate the content type againstapplication/x-www-form-urlencoded.As a result, both factories rejected valid content types that contain MIME parameters (such as
application/x-www-form-urlencoded; charset=utf-8orapplication/x-www-form-urlencoded; charset=UTF-8) or use case variants (e.g.APPLICATION/X-WWW-FORM-URLENCODEDorApplication/x-www-form-urlencoded; charset=utf-8) with anIllegalArgumentException.Per RFC 2045 §5.1, media types and subtypes are case-insensitive and parameter-agnostic for type identification. This change brings form serialization factories to parity with
TextParseNodeFactory/TextSerializationWriterFactory(#2236) andMultipartSerializationWriterFactory(#2229).Changes
fix): UpdatedFormParseNodeFactory.getParseNode()andFormSerializationWriterFactory.getSerializationWriter()to strip MIME parameters (split(";", 2)[0].trim()) and compare against the valid content type case-insensitively (equalsIgnoreCase).test): Added parameterized regression tests toParseNodeFactoryTestsandSerializationWriterFactoryTestsasserting acceptance of content types with MIME parameters and case variations, while continuing to reject delimiter-only or invalid media types.Verification
:components:serialization:form:spotlessCheck/spotlessApply: PASS:components:serialization:form:spotbugsMain/spotbugsTest: PASS:components:serialization:form:check: PASS (100% tests passing):components:bundle:check: PASS