mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Updated ActionDispatch::Request.remote_ip=
Updated the setter to clear the value in the `@remote_ip` instance variable before setting the header that the value is derived from in the getter.
This commit is contained in:
parent
a4ea17f6b6
commit
bf14a8e235
3 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
* Updated `ActionDispatch::Request.remote_ip` setter to clear set the instance
|
||||
`remote_ip` to `nil` before setting the header that the value is derived
|
||||
from.
|
||||
|
||||
Fixes https://github.com/rails/rails/issues/37383
|
||||
|
||||
*Norm Provost*
|
||||
|
||||
* `ActionController::Base.log_at` allows setting a different log level per request.
|
||||
|
||||
```ruby
|
||||
|
|
|
@ -281,6 +281,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def remote_ip=(remote_ip)
|
||||
@remote_ip = nil
|
||||
set_header "action_dispatch.remote_ip", remote_ip
|
||||
end
|
||||
|
||||
|
|
|
@ -103,6 +103,11 @@ class RequestIP < BaseRequestTest
|
|||
|
||||
request = stub_request "HTTP_X_FORWARDED_FOR" => "not_ip_address"
|
||||
assert_nil request.remote_ip
|
||||
|
||||
request = stub_request "REMOTE_ADDR" => "1.2.3.4"
|
||||
assert_equal "1.2.3.4", request.remote_ip
|
||||
request.remote_ip = "2.3.4.5"
|
||||
assert_equal "2.3.4.5", request.remote_ip
|
||||
end
|
||||
|
||||
test "remote ip spoof detection" do
|
||||
|
|
Loading…
Reference in a new issue