]> source.dussan.org Git - redmine.git/commitdiff
Merged r13018 (#16466).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 29 Mar 2014 14:54:06 +0000 (14:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 29 Mar 2014 14:54:06 +0000 (14:54 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@13028 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index d0a5b0f3d7339df90c0d9545afcbc2f79c372657..ddb6e49fa782bea8f1bf9f03638a2e641d90fc14 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? || (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
index 86b7871a4b7b2467202f189f70e4b4c32372f18f..88713770fafe4e22f9120cd55795f841d5c0f80f 100644 (file)
@@ -48,8 +48,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