@@ -379,7 +379,7 class ApplicationController < ActionController::Base | |||
|
379 | 379 | begin |
|
380 | 380 | uri = URI.parse(back_url) |
|
381 | 381 | # do not redirect user to another host or to the login or register page |
|
382 | if ((uri.relative? && back_url.match(%r{\A/\w})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) | |
|
382 | if ((uri.relative? && back_url.match(%r{\A/(\w.*)?\z})) || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) | |
|
383 | 383 | redirect_to(back_url) |
|
384 | 384 | return |
|
385 | 385 | end |
@@ -61,8 +61,14 class AccountControllerTest < ActionController::TestCase | |||
|
61 | 61 | |
|
62 | 62 | def test_login_should_redirect_to_back_url_param |
|
63 | 63 | # request.uri is "test.host" in test environment |
|
64 | post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.host/issues/show/1' | |
|
65 |
|
|
|
64 | back_urls = [ | |
|
65 | 'http://test.host/issues/show/1', | |
|
66 | '/' | |
|
67 | ] | |
|
68 | back_urls.each do |back_url| | |
|
69 | post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url | |
|
70 | assert_redirected_to back_url | |
|
71 | end | |
|
66 | 72 | end |
|
67 | 73 | |
|
68 | 74 | def test_login_should_not_redirect_to_another_host |
General Comments 0
You need to be logged in to leave comments.
Login now