diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/cgi_process.rb | 6 | ||||
-rwxr-xr-x | actionpack/test/controller/cgi_test.rb | 11 |
3 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index ebbb6f94de..62feda696b 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that ActionController::CgiRequest#host_with_port() should handle standard port #10082 [moro] + * Update Prototype to 1.6.0 and script.aculo.us to 1.8.0. [sam, madrobby] * Expose the cookie jar as a helper method (before the view would just get the raw cookie hash) [DHH] diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index adc594f03e..b3739ce399 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -82,7 +82,7 @@ module ActionController #:nodoc: @cgi.cookies.freeze end - def host_with_port + def host_with_port_without_standard_port_handling if forwarded = env["HTTP_X_FORWARDED_HOST"] forwarded.split(/,\s?/).last elsif http_host = env['HTTP_HOST'] @@ -95,11 +95,11 @@ module ActionController #:nodoc: end def host - host_with_port.sub(/:\d+$/, '') + host_with_port_without_standard_port_handling.sub(/:\d+$/, '') end def port - if host_with_port =~ /:(\d+)$/ + if host_with_port_without_standard_port_handling =~ /:(\d+)$/ $1.to_i else standard_port diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index fe94d7c7a6..cf9d5d163e 100755 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -47,6 +47,17 @@ class CgiRequestTest < BaseCgiTest assert_equal "207.7.108.53:8007", @request.host_with_port end + def test_host_with_port_if_http_standard_port_is_specified + @request_hash['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:80" + assert_equal "glu.ttono.us", @request.host_with_port + end + + def test_host_with_port_if_https_standard_port_is_specified + @request_hash['HTTP_X_FORWARDED_PROTO'] = "https" + @request_hash['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:443" + assert_equal "glu.ttono.us", @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]" |