Compare commits

...

6 Commits

Author SHA1 Message Date
Xavier Noria
e8c05974e1 Merge pull request #5653 from eee-c/patch-1
Doc fixes in 2.3: validates_length_of
2012-03-29 06:26:32 -07:00
Chris Strom
2229a7e8e8 Better minimum validates_length_of examples (adapted from master). 2012-03-29 09:27:23 -03:00
José Valim
8fff8f0410 Merge pull request #4247 from amatsuda/hashdos_23
bump up rack version to the one that includes the Hash DoS fix
2011-12-31 05:09:14 -08:00
Akira Matsuda
27a508c91e bump up rack version to the one that includes the Hash DoS fix 2011-12-31 22:02:09 +09:00
Aaron Patterson
2eb197e72f Merge pull request #4202 from dasch/request-remote-ip
Fix bug in `ActionController::Request#remote_ip`
2011-12-29 08:10:53 -08:00
Daniel Schierbeck
cd2136aed6 Make Request#remote_ip return nil when HTTP_X_FORWARDED_FOR is empty
If HTTP_X_FORWARDED_FOR only contains whitespace, don't try to extract a
list of IP addresses from it.
2011-12-27 13:56:11 +01:00
5 changed files with 11 additions and 8 deletions

View File

@@ -79,7 +79,7 @@ spec = Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency('activesupport', '= 2.3.14' + PKG_BUILD)
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack', '~> 1.1.3')
s.require_path = 'lib'

View File

@@ -31,7 +31,7 @@ rescue LoadError
end
end
gem 'rack', '~> 1.1.0'
gem 'rack', '~> 1.1.3'
require 'rack'
require 'action_controller/cgi_ext'

View File

@@ -225,7 +225,7 @@ module ActionController
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(',')
remote_ips = @env['HTTP_X_FORWARDED_FOR'].present? && @env['HTTP_X_FORWARDED_FOR'].split(',')
if @env.include? 'HTTP_CLIENT_IP'
if ActionController::Base.ip_spoofing_check && remote_ips && !remote_ips.include?(@env['HTTP_CLIENT_IP'])

View File

@@ -20,6 +20,9 @@ class RequestTest < ActiveSupport::TestCase
'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
assert_equal '1.2.3.4', request.remote_ip
request = stub_request 'HTTP_X_FORWARDED_FOR' => ''
assert_nil request.remote_ip
request = stub_request 'REMOTE_ADDR' => '127.0.0.1',
'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
assert_equal '3.4.5.6', request.remote_ip

View File

@@ -602,14 +602,14 @@ module ActiveRecord
# Validates that the specified attribute matches the length restrictions supplied. Only one option can be used at a time:
#
# class Person < ActiveRecord::Base
# validates_length_of :first_name, :maximum=>30
# validates_length_of :last_name, :maximum=>30, :message=>"less than %{count} if you don't mind"
# validates_length_of :first_name, :maximum => 30
# validates_length_of :last_name, :maximum => 30, :message => "less than %{count} if you don't mind"
# validates_length_of :fax, :in => 7..32, :allow_nil => true
# validates_length_of :phone, :in => 7..32, :allow_blank => true
# validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
# validates_length_of :fav_bra_size, :minimum => 1, :too_short => "please enter at least %{count} character"
# validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with %{count} characters... don't play me."
# validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %{count} words."), :tokenizer => lambda {|str| str.scan(/\w+/) }
# validates_length_of :zip_code, :minimum => 5, :too_short => "please enter at least %{count} characters"
# validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with %{count} characters... don't play me"
# validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %{count} words"), :tokenizer => lambda {|str| str.scan(/\w+/) }
# end
#
# Configuration options: