From 0565e3371ee4c7531081699b1c477f653d617404 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 5 Apr 2014 14:33:32 +0000 Subject: [PATCH] Merged r13040 (#16467). git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@13045 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/application_controller.rb | 2 +- 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 ddb6e49fa..449890eec 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? && back_url.match(%r{\A/\w})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) + if ((uri.relative? && back_url.match(%r{\A/(\w.*)?\z})) || (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 88713770f..e77009e16 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -43,8 +43,14 @@ class AccountControllerTest < ActionController::TestCase def test_login_should_redirect_to_back_url_param # request.uri is "test.host" in test environment - post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1' - assert_redirected_to '/issues/show/1' + back_urls = [ + 'http://test.host/issues/show/1', + '/' + ] + back_urls.each do |back_url| + post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url + assert_redirected_to back_url + end end def test_login_should_not_redirect_to_another_host -- 2.39.5