Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed force_ssl redirects to include original query params

`ActionController.force_ssl` redirects http URLs to their https equivalent;
however, when a URL contains a query string, the resulting redirect lacked the
original query string.

Conflicts:

	actionpack/lib/action_controller/metal/force_ssl.rb
  • Loading branch information...
commit 6efb849b32f672d9c26f36d2c823b134f49bd892 1 parent 275c3a1
@rmm5t rmm5t authored
View
1  actionpack/lib/action_controller/metal/force_ssl.rb
@@ -29,6 +29,7 @@ def force_ssl(options = {})
if !request.ssl? && !Rails.env.development?
redirect_options = {:protocol => 'https://', :status => :moved_permanently}
redirect_options.merge!(:host => host) if host
+ redirect_options.merge!(:params => request.query_parameters)
flash.keep
redirect_to redirect_options
end
View
1  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -567,6 +567,7 @@ def url_for(options)
path_addition, params = generate(path_options, path_segments || {})
path << path_addition
+ params.merge!(options[:params] || {})
ActionDispatch::Http::URL.url_for(options.merge!({
:path => path,
View
6 actionpack/test/controller/force_ssl_test.rb
@@ -50,6 +50,12 @@ def test_banana_redirects_to_https
assert_equal "https://test.host/force_ssl_controller_level/banana", redirect_to_url
end
+ def test_banana_redirects_to_https_with_extra_params
+ get :banana, :token => "secret"
+ assert_response 301
+ assert_equal "https://test.host/force_ssl_controller_level/banana?token=secret", redirect_to_url
+ end
+
def test_cheeseburger_redirects_to_https
get :cheeseburger
assert_response 301
Please sign in to comment.
Something went wrong with that request. Please try again.