Skip to content

Commit

Permalink
Merge pull request #1506 from sinatra/fix-1478
Browse files Browse the repository at this point in the history
avoid FrozenError when params contains frozen value
  • Loading branch information
namusyaka committed Dec 16, 2018
2 parents 38e5d63 + c686a10 commit 9057b70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinatra/base.rb
Expand Up @@ -1089,7 +1089,7 @@ def invoke

# Dispatch a request with error handling.
def dispatch!
force_encoding(@params.merge!(@request.params))
@params.merge!(@request.params).each { |key, val| @params[key] = force_encoding(val.dup) }

invoke do
static! if settings.static? && (request.get? || request.head?)
Expand Down
13 changes: 13 additions & 0 deletions test/middleware_test.rb
Expand Up @@ -65,4 +65,17 @@ def call(env)
assert_equal "/FOO", body
assert_equal "UpcaseMiddleware", response['X-Tests']
end

class FreezeMiddleware < MockMiddleware
def call(env)
req = Rack::Request.new(env)
req.update_param('bar', 'baz'.freeze)
super
end
end

it "works when middleware adds a frozen param" do
@app.use FreezeMiddleware
get '/Foo'
end
end

0 comments on commit 9057b70

Please sign in to comment.