mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 06:46:01 +01:00
Redirection after signing in fails when the back_url includes a port number (#41930).
Patch by Kenta Kumojima (user:kumojima) and Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@23465 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -511,11 +511,9 @@ class ApplicationController < ActionController::Base
|
|||||||
if uri.send(component).present? && uri.send(component) != request.send(component)
|
if uri.send(component).present? && uri.send(component) != request.send(component)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
uri.send(:"#{component}=", nil)
|
|
||||||
end
|
end
|
||||||
# Always ignore basic user:password in the URL
|
# Remove unnecessary components to convert the URL into a relative URL
|
||||||
uri.userinfo = nil
|
uri.omit!(:scheme, :userinfo, :host, :port)
|
||||||
rescue Addressable::URI::InvalidURIError
|
rescue Addressable::URI::InvalidURIError
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -658,4 +658,22 @@ class AccountControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_validate_back_url
|
||||||
|
request.host = 'example.com'
|
||||||
|
|
||||||
|
assert_equal '/admin', @controller.send(:validate_back_url, 'http://example.com/admin')
|
||||||
|
assert_equal '/admin', @controller.send(:validate_back_url, 'http://dlopper:foo@example.com/admin')
|
||||||
|
assert_equal '/issues?query_id=1#top', @controller.send(:validate_back_url, 'http://example.com/issues?query_id=1#top')
|
||||||
|
assert_equal false, @controller.send(:validate_back_url, 'http://invalid.example.com/issues')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_validate_back_url_with_port
|
||||||
|
request.host = 'example.com:3000'
|
||||||
|
|
||||||
|
assert_equal '/admin', @controller.send(:validate_back_url, 'http://example.com:3000/admin')
|
||||||
|
assert_equal '/admin', @controller.send(:validate_back_url, 'http://dlopper:foo@example.com:3000/admin')
|
||||||
|
assert_equal '/issues?query_id=1#top', @controller.send(:validate_back_url, 'http://example.com:3000/issues?query_id=1#top')
|
||||||
|
assert_equal false, @controller.send(:validate_back_url, 'http://invalid.example.com:3000/issues')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user