Skip to content

Shares quote-aware charset parsing with form encoders - #3674

Merged
velo merged 1 commit into
OpenFeign:masterfrom
hutiefang76:frank/fix-shared-content-type-charset-20261110
Nov 10, 2026
Merged

velo merged 1 commit into
OpenFeign:masterfrom
hutiefang76:frank/fix-shared-content-type-charset-20261110

Conversation

@hutiefang76

Copy link
Copy Markdown
Contributor

FormEncoder can select a charset from text inside another quoted parameter. For example, note="x;charset=ISO-8859-1" makes name=é encode as name=%E9, even though the request has no charset parameter. It should use the existing UTF-8 default and emit name=%C3%A9.

Move the existing quote-aware Response scanner into the experimental Util.charsetOfContentType helper and use it from both Response and FormEncoder. This also prevents xcharset from selecting an encoding and makes form parameter whitespace handling consistent with Response. Response retains its header-order selection and UTF-8 fallback; FormEncoder still reads the first non-null Content-Type value. Malformed values follow the existing Response scanner rather than the old regex's partial matches.

Follows up the shared-helper suggestions in #3611 and #3628. Includes five encoding/header regressions, two Response header-order controls, seven direct helper tests, and form charset documentation. No new dependencies or POM changes.

Validation with JDK 8 main compilation and JDK 25 tests, keeping the dev profile enabled:

  • Unchanged production baseline: 29 tests, with the five new form regressions failing assertions and both new Response controls passing; no errors.
  • Focused Response, Util, DefaultDecoder and FormEncoderCharset tests: 70 passed.
  • mvn -Pdev -pl core,slf4j,form,form-spring -am clean install: 1,008 tests reported, 1,004 passed, four existing conditional skips, zero failures or errors; six projects succeeded. SLF4J is explicit because the form-spring test starter references it transitively.
  • mvn -Pdev validate: 56 projects succeeded.

AI-assisted implementation and code review; the validation above was executed locally.

Reuse the response parameter scanner through an experimental Util helper
so quoted charset text cannot select the form request encoding. Keep
caller header selection and UTF-8 fallback policies.

Cover encoding, header ordering and the shared helper contract, and
document form charset selection.

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct fix: FormEncoder now shares Response's quote-aware charset scanner, so charset text inside other parameters or longer parameter names no longer selects the encoding. Response behaviour is unchanged and the public API addition is @Experimental. Thanks!

@velo
velo merged commit b918d54 into OpenFeign:master Nov 10, 2026
3 checks passed
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.

2 participants