Add QueryStringDecoder option to leave '+' alone#14850
Merged
normanmaurer merged 3 commits intonetty:4.1from Feb 24, 2025
Merged
Add QueryStringDecoder option to leave '+' alone#14850normanmaurer merged 3 commits intonetty:4.1from
normanmaurer merged 3 commits intonetty:4.1from
Conversation
Motivation: The URI standard RFC 3986 does not specify that query components have their spaces encoded as `+`. It is implied that the encoding is `%20` instead. However, the whatwg HTML standard says explicitly that the query must be encoded using `application/x-www-form-urlencoded` rules, which does use `+` for space. This is also what browsers do. QueryStringDecoder should offer a way to parse either format. Modification: - Modify QueryStringDecoder to use a builder to accommodate the increasing number of flags - Add a `htmlQueryDecoding` flag, enabled by default, to control the `+` decoding The default value of `htmlQueryDecoding` is appropriate for most use cases, I don't think it should be changed even in netty 5. Result: Query strings encoded purely according to the URI spec can be decoded properly.
chrisvest
approved these changes
Feb 21, 2025
chrisvest
reviewed
Feb 21, 2025
…obenchmark.java Co-authored-by: Chris Vest <mr.chrisvest@gmail.com>
normanmaurer
approved these changes
Feb 24, 2025
Member
|
@yawkat thanks a lot! |
normanmaurer
pushed a commit
that referenced
this pull request
Feb 24, 2025
Motivation: The URI standard RFC 3986 does not specify that query components have their spaces encoded as `+`. It is implied that the encoding is `%20` instead. However, the whatwg HTML standard says explicitly that the query must be encoded using `application/x-www-form-urlencoded` rules, which does use `+` for space. This is also what browsers do. QueryStringDecoder should offer a way to parse either format. Modification: - Modify QueryStringDecoder to use a builder to accommodate the increasing number of flags - Add a `htmlQueryDecoding` flag, enabled by default, to control the `+` decoding The default value of `htmlQueryDecoding` is appropriate for most use cases, I don't think it should be changed even in netty 5. Also fixed the benchmark harness for Java 21. Result: Query strings encoded purely according to the URI spec can be decoded properly. I measured the performance of the new builder, and it didn't look any different. --------- Co-authored-by: Chris Vest <mr.chrisvest@gmail.com>
normanmaurer
added a commit
that referenced
this pull request
Feb 24, 2025
Motivation: The URI standard RFC 3986 does not specify that query components have their spaces encoded as `+`. It is implied that the encoding is `%20` instead. However, the whatwg HTML standard says explicitly that the query must be encoded using `application/x-www-form-urlencoded` rules, which does use `+` for space. This is also what browsers do. QueryStringDecoder should offer a way to parse either format. Modification: - Modify QueryStringDecoder to use a builder to accommodate the increasing number of flags - Add a `htmlQueryDecoding` flag, enabled by default, to control the `+` decoding The default value of `htmlQueryDecoding` is appropriate for most use cases, I don't think it should be changed even in netty 5. Also fixed the benchmark harness for Java 21. Result: Query strings encoded purely according to the URI spec can be decoded properly. I measured the performance of the new builder, and it didn't look any different. Co-authored-by: Jonas Konrad <me@yawk.at> Co-authored-by: Chris Vest <mr.chrisvest@gmail.com>
normanmaurer
added a commit
that referenced
this pull request
Feb 24, 2025
Motivation: The URI standard RFC 3986 does not specify that query components have their spaces encoded as `+`. It is implied that the encoding is `%20` instead. However, the whatwg HTML standard says explicitly that the query must be encoded using `application/x-www-form-urlencoded` rules, which does use `+` for space. This is also what browsers do. QueryStringDecoder should offer a way to parse either format. Modification: - Modify QueryStringDecoder to use a builder to accommodate the increasing number of flags - Add a `htmlQueryDecoding` flag, enabled by default, to control the `+` decoding The default value of `htmlQueryDecoding` is appropriate for most use cases, I don't think it should be changed even in netty 5. Also fixed the benchmark harness for Java 21. Result: Query strings encoded purely according to the URI spec can be decoded properly. I measured the performance of the new builder, and it didn't look any different. Co-authored-by: Jonas Konrad <me@yawk.at> Co-authored-by: Chris Vest <mr.chrisvest@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
The URI standard RFC 3986 does not specify that query components have their spaces encoded as
+. It is implied that the encoding is%20instead. However, the whatwg HTML standard says explicitly that the query must be encoded usingapplication/x-www-form-urlencodedrules, which does use+for space. This is also what browsers do.QueryStringDecoder should offer a way to parse either format.
Modification:
htmlQueryDecodingflag, enabled by default, to control the+decodingThe default value of
htmlQueryDecodingis appropriate for most use cases, I don't think it should be changed even in netty 5.Also fixed the benchmark harness for Java 21.
Result:
Query strings encoded purely according to the URI spec can be decoded properly.
I measured the performance of the new builder, and it didn't look any different.