Skip to content

encode collection values in urlencoded form bodies#3436

Merged
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:urlencoded-form-collection-encode
Jun 23, 2026
Merged

encode collection values in urlencoded form bodies#3436
velo merged 1 commit into
OpenFeign:masterfrom
alhudz:urlencoded-form-collection-encode

Conversation

@alhudz

@alhudz alhudz commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Repro: post an application/x-www-form-urlencoded form whose value is a collection or array, e.g. a tags field of ["a&b=c", "d"]. The body comes out as tags=a&b=c&tags=d, smuggling an extra b=c field into the request the downstream service parses.
Cause: UrlencodedFormContentProcessor.createKeyValuePair collects collection and array values with Object::toString and passes them to CollectionFormat.join, which encodes the field name and the separator but writes each value verbatim. The scalar path already runs values through encode, so only collection-valued fields leak reserved characters.
Fix: encode each collection value with the same encode(value, charset) helper before the join, matching the scalar path. QueryTemplate is the only other CollectionFormat.join caller and already passes pre-encoded values, so join itself is left untouched. Added regression tests for the array and collection paths.

@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.

Good catch on the collection-valued form path. Encoding the values before handing them to CollectionFormat matches the scalar behavior, and the array/collection regressions cover the failure mode clearly.

@velo velo merged commit 3062e80 into OpenFeign:master Jun 23, 2026
3 checks passed
@velo velo mentioned this pull request Jun 23, 2026
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