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

Use Rack::QueryParser with nil missing value. #47652

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions actionpack/lib/action_dispatch/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,20 @@ def session_options=(options)
Session::Options.set self, options
end

if Rack.release >= "3"
class QueryParser < ::Rack::QueryParser
def missing_value
nil
end
end

QUERY_PARSER = QueryParser.make_default(32)

def query_parser
QUERY_PARSER
end
end

# Override Rack's GET method to support indifferent access.
def GET
fetch_header("action_dispatch.request.query_parameters") do |k|
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/test_case_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def to_param
def test_body_stream
params = Hash[:page, { name: "page name" }, "some key", 123]

post :render_body, params: params.dup
post :render_body, body: params.to_query

assert_equal params.to_query, @response.body
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def assert_parses(expected, actual)
middleware.use(EarlyParse)
end

get "/parse", params: actual
get "/parse?#{actual}"
assert_response :ok
assert_equal(expected, ::QueryStringParsingTest::TestController.last_query_parameters)
end
Expand Down