]> source.dussan.org Git - redmine.git/commitdiff
Fixed that back_url=/ param is ignored (#16467).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Apr 2014 08:11:28 +0000 (08:11 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Apr 2014 08:11:28 +0000 (08:11 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13040 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
test/functional/account_controller_test.rb

index 1e251c2a4a4963a52341da6d4e24a3bf8c239614..5e5b297c242d5dee687bb02f310b73f1c7d72bac 100644 (file)
@@ -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
index e9156957c802939ecd7abcb0960bfe9572492c3d..991a8fb72f9e895a4e81770d2e0c715e76513e9d 100644 (file)
@@ -61,8 +61,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