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
Make query string parsing conform to URL spec #1699
Make query string parsing conform to URL spec #1699
Conversation
The implications of this change are:
As an alternative to specify
|
You are correct about the implications. In general, you should omit the parameter if it should have a nil value. That's more of an implicit nil, this would remove the explicit nil. Correct that this will change behavior and can break things that depend on nil values. That's why I labeled it a breaking change in the CHANGELOG. Looks like the result of A somewhat informal explanation of query parsing types using an algebraic data types: A QueryParseResult (result of A QueryParseValue is either a:
|
I basically agree with this but I'm concerned about the blast radius of this change. |
@@ -86,6 +86,7 @@ def normalize_params(params, name, v, depth) | |||
name =~ %r(\A[\[\]]*([^\[\]]+)\]*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you can tidy up this parsing logic a bit? Using $
variables concerns me a little.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can, but I don't see the reason to do so in this PR. It's better to keep the implementation the same as before. After all, there are other $
variables used elsewhere in the code, including later in this method. If you would like to remove $
variable usage, we should probably do that globally in a separate PR.
The URL spec section 5.1.3.3 specifies that if = is not present in the byte sequence, it should be treated as if the byte sequence is the name of the tuple and the value is the empty string. This affects all parameters without =, not just arrays: ```ruby Rack::Utils.parse_nested_query("foo[bar]&baz[]&quux") {"foo"=>{"bar"=>nil}, "baz"=>[nil], "quux"=>nil} # Before {"foo"=>{"bar"=>""}, "baz"=>[""], "quux"=>""} # After ``` Fixes rack#1696
26afb6a
to
92eb2a5
Compare
The URL spec section 5.1.3.3 specifies that if = is not present
in the byte sequence, it should be treated as if the byte sequence
is the name of the tuple and the value is the empty string.
This affects all parameters without =, not just arrays:
Fixes #1696