Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix x-www-form-urlencoded parsing for no-value key (re-submission) #13908

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

jeremyg484
Copy link
Contributor

Motivation:

According to the specification for parsing of
application/x-www-form-urlencoded content at
https://url.spec.whatwg.org/#application/x-www-form-urlencoded, a key
without an = should be able to be parsed and given an empty value. The
current implementation of HttpPostStandardRequestDecoder fails to parse
these no-value keys when they are the last value in the sequence.

Modifications:

HttpPostStandardRequestDecoder is modified to include a key with no
value that is at the end of the undecoded chunk in the existing "special
empty FIELD" code path that currently only handles such fields when they
are followed by a '&' character.

Additional tests are provided to throroughly exercise variations of
content bodies with such empty fields.

A test has also been added to verify that the change works with an empty
last chunk, as suggested in the original PR #13904

Result:

Keys with no value that appear at the end of a x-www-form-urlencoded
sequence will be parsed according to the spec.

Motivation:

According to the specification for parsing of
application/x-www-form-urlencoded content at
https://url.spec.whatwg.org/#application/x-www-form-urlencoded, a key
without an = should be able to be parsed and given an empty value. The
current implementation of HttpPostStandardRequestDecoder fails to parse
these no-value keys when they are the last value in the sequence.

Modifications:

HttpPostStandardRequestDecoder is modified to include a key with no
value that is at the end of the undecoded chunk in the existing "special
empty FIELD" code path that currently only handles such fields when they
are followed by a '&' character.

Additional tests are provided to throroughly exercise variations of
content bodies with such empty fields.

Result:

Keys with no value that appear at the end of a x-www-form-urlencoded
sequence will be parsed according to the spec.
@normanmaurer
Copy link
Member

@yawkat PTAL

@normanmaurer normanmaurer added this to the 4.1.108.Final milestone Mar 15, 2024
@normanmaurer normanmaurer merged commit 2da1fd7 into netty:4.1 Mar 15, 2024
15 checks passed
@normanmaurer
Copy link
Member

@yawkat @jeremyg484 thanks a lot!

@yawkat
Copy link
Contributor

yawkat commented Mar 15, 2024

thanks!

@yawkat
Copy link
Contributor

yawkat commented Mar 15, 2024

also, this seems like a prime target for fuzzing. if i ever get approval to work on that...

gniadeck added a commit to gniadeck/netty that referenced this pull request Apr 23, 2024
Motivation:

This is a fix for issue netty#13981 that reports a changed behaviour of HttpPostStandardRequestDecoder after this PR - netty#13908

Because HttpPostStandardRequestDecoder changed the contract, some code implementations relying on certain parsing are failing

Modification:

This PR makes sure, that the edge case handling for form data happenes only when the content is in fact form data

Result:

Fixes netty#13981
normanmaurer pushed a commit that referenced this pull request Apr 27, 2024
Motivation:

This is a fix for issue #13981 that reports a changed behaviour of
HttpPostStandardRequestDecoder after this PR -
#13908

Because HttpPostStandardRequestDecoder changed the contract, some code
implementations relying on certain parsing are failing


Modification:

This PR makes sure, that the edge case handling for form body happenes
only when the content is in fact form body

Result:

Fixes #13981
normanmaurer pushed a commit that referenced this pull request Apr 27, 2024
Motivation:

This is a fix for issue #13981 that reports a changed behaviour of
HttpPostStandardRequestDecoder after this PR -
#13908

Because HttpPostStandardRequestDecoder changed the contract, some code
implementations relying on certain parsing are failing


Modification:

This PR makes sure, that the edge case handling for form body happenes
only when the content is in fact form body

Result:

Fixes #13981
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.

3 participants