diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-03-29 14:32:47 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-03-29 14:32:47 +0000 |
commit | 7567c3d8b21fe67e5f04e6839c1fce061600f2f3 (patch) | |
tree | eae4d51cac62e1971e3f862713a8b2934dbd2529 | |
parent | cecbb225a25c41b11680744fc1162294600c4733 (diff) | |
download | redmine-7567c3d8b21fe67e5f04e6839c1fce061600f2f3.tar.gz redmine-7567c3d8b21fe67e5f04e6839c1fce061600f2f3.zip |
Fixed back url verification (#16466).
git-svn-id: http://svn.redmine.org/redmine/trunk@13018 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | test/functional/account_controller_test.rb | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 43257b2bf..1e251c2a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -379,7 +379,7 @@ class ApplicationController < ActionController::Base begin uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page - if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) + if ((uri.relative? && back_url.match(%r{\A/\w})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) redirect_to(back_url) return end diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 35074bd4e..e9156957c 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -66,8 +66,14 @@ class AccountControllerTest < ActionController::TestCase end def test_login_should_not_redirect_to_another_host - post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.foo/fake' - assert_redirected_to '/my/page' + back_urls = [ + 'http://test.foo/fake', + '//test.foo/fake' + ] + back_urls.each do |back_url| + post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url + assert_redirected_to '/my/page' + end end def test_login_with_wrong_password |