diff options
author | adam <code@getbraintree.com> | 2015-03-20 20:30:30 +0000 |
---|---|---|
committer | adam <code@getbraintree.com> | 2015-03-20 20:32:30 +0000 |
commit | b49cac80de2d0245d8a704eebf555c54371b41d8 (patch) | |
tree | 14016e73a0ab9f51e1c9196411f4f29579556ba5 /actionpack/lib/action_dispatch | |
parent | 013b716f384a090f189ea7a98efd4c4171555454 (diff) | |
download | rails-b49cac80de2d0245d8a704eebf555c54371b41d8.tar.gz rails-b49cac80de2d0245d8a704eebf555c54371b41d8.tar.bz2 rails-b49cac80de2d0245d8a704eebf555c54371b41d8.zip |
Fix handling of empty X_FORWARDED_HOST header.
Previously, an empty X_FORWARDED_HOST header would cause
Actiondispatch::Http:URL.raw_host_with_port to return nil, causing
Actiondispatch::Http:URL.host to raise a NoMethodError.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 7da6301ac4..f5b709ccd6 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -229,7 +229,7 @@ module ActionDispatch # req = Request.new 'HTTP_HOST' => 'example.com:8080' # req.raw_host_with_port # => "example.com:8080" def raw_host_with_port - if forwarded = env["HTTP_X_FORWARDED_HOST"] + if forwarded = env["HTTP_X_FORWARDED_HOST"].presence forwarded.split(/,\s?/).last else env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}" |