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

avoid FrozenError when params contains frozen value #1506

Merged
merged 1 commit into from Dec 16, 2018
Merged
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
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