Skip to content

Commit

Permalink
Use Rack::QueryParser with nil missing value.
Browse files Browse the repository at this point in the history
Rack 3 follows the WhatWG standard for the query parser. This deviates from
Rack 2 as `?a` as a query string is was previously interpreted as
`{"a" => nil}` but is now interpreted as `{"a" => ""}`. Rails depends on
the previous behaviour for compatibility, so we introduced hooks into Rack
to restore compatibility.
  • Loading branch information
ioquatix committed Mar 13, 2023
1 parent 3025eaa commit f336b47
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit f336b47

Please sign in to comment.