FIX: handle array in redirect param
This commit is contained in:
parent
f4fd75aea4
commit
e2636f0ec7
|
@ -89,10 +89,11 @@ class StaticController < ApplicationController
|
|||
|
||||
destination = 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)
|
||||
begin
|
||||
forum_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) &&
|
||||
|
|
|
@ -283,6 +283,13 @@ describe StaticController do
|
|||
end
|
||||
end
|
||||
|
||||
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' do
|
||||
it 'redirects to the root url' do
|
||||
post "/login.json", params: { redirect: login_path }
|
||||
|
|
Loading…
Reference in New Issue