diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-08-31 19:03:42 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-08-31 19:03:42 +0000 |
commit | 33e5e41ddaf59bc9c08e4d9eb34d52174bf05114 (patch) | |
tree | 82ba138ac1d2652bc88f65c81ed2efbc16574e7c | |
parent | 55efae2387b0542e6f943f8a3d50290c7b06ae80 (diff) | |
download | rails-33e5e41ddaf59bc9c08e4d9eb34d52174bf05114.tar.gz rails-33e5e41ddaf59bc9c08e4d9eb34d52174bf05114.tar.bz2 rails-33e5e41ddaf59bc9c08e4d9eb34d52174bf05114.zip |
request.host works with IPv6 addresses. Closes #9458.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7382 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 2 | ||||
-rwxr-xr-x | actionpack/test/controller/cgi_test.rb | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9eab683587..0d679f93e2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* request.host works with IPv6 addresses. #9458 [yuya] + * Fix bug where action caching sets the content type to the ActionCachePath object. Closes #9282 [mindforge] * Find layouts even if they're not in the first view_paths directory. Closes #9258 [caio] diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index fa7afd4197..6e8098e746 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -92,7 +92,7 @@ module ActionController #:nodoc: end def host - host_with_port[/^[^:]+/] + host_with_port.sub(/:\d+$/, '') end def port diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index a5b24ebcd4..fe94d7c7a6 100755 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -47,6 +47,18 @@ class CgiRequestTest < BaseCgiTest assert_equal "207.7.108.53:8007", @request.host_with_port end + def test_host_if_ipv6_reference + @request_hash.delete "HTTP_X_FORWARDED_HOST" + @request_hash['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]" + assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host + end + + def test_host_if_ipv6_reference_with_port + @request_hash.delete "HTTP_X_FORWARDED_HOST" + @request_hash['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]:8008" + assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host + end + def test_cookie_syntax_resilience cookies = CGI::Cookie::parse(@request_hash["HTTP_COOKIE"]); assert_equal ["c84ace84796670c052c6ceb2451fb0f2"], cookies["_session_id"] |