diff options
author | Michael S. Klishin <michael@novemberain.com> | 2008-07-01 11:52:20 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-27 23:03:11 -0700 |
commit | e42a235dd18a39ccc83382365088de96f24fa236 (patch) | |
tree | b3b2ecd628fa70ab6fbc8ec0649d6b044b2f285d /actionpack/lib/action_controller | |
parent | c2068d14d29ec767c681798b3814f0a8e22fb0ff (diff) | |
download | rails-e42a235dd18a39ccc83382365088de96f24fa236.tar.gz rails-e42a235dd18a39ccc83382365088de96f24fa236.tar.bz2 rails-e42a235dd18a39ccc83382365088de96f24fa236.zip |
Request#remote_ip handles the uncommon case that REMOTE_ADDR is a comma-separated list.
[#523 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x[-rw-r--r--] | actionpack/lib/action_controller/request.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 364e6201cc..d793ade702 100644..100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -197,10 +197,12 @@ module ActionController # delimited list in the case of multiple chained proxies; the last # address which is not trusted is the originating IP. def remote_ip - if TRUSTED_PROXIES !~ @env['REMOTE_ADDR'] - return @env['REMOTE_ADDR'] - end + remote_addr_list = @env['REMOTE_ADDR'] && @env['REMOTE_ADDR'].split(',').collect(&:strip) + unless remote_addr_list.blank? + not_trusted_addrs = remote_addr_list.reject {|addr| addr =~ TRUSTED_PROXIES} + return not_trusted_addrs.first unless not_trusted_addrs.empty? + end remote_ips = @env['HTTP_X_FORWARDED_FOR'] && @env['HTTP_X_FORWARDED_FOR'].split(',') if @env.include? 'HTTP_CLIENT_IP' |