Repository navigation
fix(serialization): support content-type parameters and case-insensitivity in form factories - #2239
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>
|
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 |
|
Thanks Vincent Biret (@baywet) |
|
Hi Vincent Biret (@baywet) , whenever you get a chance, could you please review this PR and merge it if everything looks good? Thank you for your time! |
Install the Java 8 compiler required by -Pjava8=true instead of relying on the hosted runner image. Keep Java 21 as the default JVM for Gradle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: de23e4a2-18d4-4f3f-a50e-d16751ed83b7 Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Head branch was pushed to by a user without write access
|
Cherry-picked the JDK 8 toolchain fix from #2249 — the ubuntu-latest runner image dropped Java 8, so the |
|
Blocked by #2249, which explicitly installs the Java 8 toolchain required by the build workflow on Ubuntu 26.04. The corrected Java 8 build passes on that PR, and auto-merge is enabled. |
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
(I'm not sure my approval will count since the last commit is mine)
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