Skip to content

Commit 7567c3d

Browse files
committed
Fixed back url verification (#16466).
git-svn-id: http://svn.redmine.org/redmine/trunk@13018 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent cecbb22 commit 7567c3d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Diff for: app/controllers/application_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def redirect_back_or_default(default, options={})
379379
begin
380380
uri = URI.parse(back_url)
381381
# do not redirect user to another host or to the login or register page
382-
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
382+
if ((uri.relative? && back_url.match(%r{\A/\w})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
383383
redirect_to(back_url)
384384
return
385385
end

Diff for: test/functional/account_controller_test.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ def test_login_should_redirect_to_back_url_param
6666
end
6767

6868
def test_login_should_not_redirect_to_another_host
69-
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.foo/fake'
70-
assert_redirected_to '/my/page'
69+
back_urls = [
70+
'http://test.foo/fake',
71+
'//test.foo/fake'
72+
]
73+
back_urls.each do |back_url|
74+
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url
75+
assert_redirected_to '/my/page'
76+
end
7177
end
7278

7379
def test_login_with_wrong_password

0 commit comments

Comments
 (0)