A platform for community discussion. Free, open, simple.
FIX: handle array in redirect param
Arpit Jalane2636f0ec7a2
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rbindex b940641f4c0..991c9c9941f 100644--- a/app/controllers/static_controller.rb+++ b/app/controllers/static_controller.rb@@ -89,10 +89,11 @@ class StaticController < ApplicationControllerdestination = path("/")- if params[:redirect].present? && !params[:redirect].match(login_path)+ redirect_location = params[:redirect].to_s+ if redirect_location.present? && !redirect_location.match(login_path)beginforum_uri = URI(Discourse.base_url)- uri = URI(params[:redirect])+ uri = URI(redirect_location)if uri.path.present? &&(uri.host.blank? || uri.host == forum_uri.host) &&diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rbindex 5553328c788..73ce3ff90bb 100644--- a/spec/requests/static_controller_spec.rb+++ b/spec/requests/static_controller_spec.rb@@ -283,6 +283,13 @@ describe StaticController doendend+ context 'with an array' do+ it "redirects to the root" do+ post "/login.json", params: { redirect: ["/foo"] }+ expect(response).to redirect_to('/')+ end+ end+context 'when the redirect path is the login page' doit 'redirects to the root url' dopost "/login.json", params: { redirect: login_path }