Skip to content

Read quoted and mixed-case charset parameters in FormEncoder - #3611

Open
kdelay wants to merge 1 commit into
OpenFeign:masterfrom
kdelay:fix/form-charset-param
Open

kdelay wants to merge 1 commit into
OpenFeign:masterfrom
kdelay:fix/form-charset-param

Conversation

@kdelay

@kdelay kdelay commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

FormEncoder reads the charset with (?<=charset=)([\w\-]+), which is case-sensitive and stops at a quote. With

  • Content-Type: application/x-www-form-urlencoded; Charset=ISO-8859-1
  • Content-Type: application/x-www-form-urlencoded; charset="ISO-8859-1"

the body is encoded as UTF-8 (name=%C3%A9 instead of name=%E9) and the header is rewritten to charset=UTF-8. Both forms are valid per RFC 9110 8.3.1, and Response.charset() already reads them.

The pattern now ignores case and accepts an optional opening quote.

Two tests in FormEncoderCharsetTest fail without the change. mvn -pl form,form-spring install passes.

FormEncoder looked for the charset with a case-sensitive pattern that
did not accept a quoted value, so Content-Type headers such as
'Charset=ISO-8859-1' or 'charset="ISO-8859-1"' fell back to UTF-8 and
the header was rewritten to charset=UTF-8. Parameter names are
case-insensitive and values may be quoted (RFC 9110 8.3.1), and
Response.charset() already reads both forms.

Signed-off-by: kdelay <kdelay20@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant