Update RemoteIp patch with Rails 8.1 changes (#38139)

This commit is contained in:
Matt Jankowski
2026-03-11 05:51:49 -04:00
committed by GitHub
parent 32fc5304a7
commit 53f4d7f029

View File

@@ -17,11 +17,11 @@ module ActionDispatch
module GetIpExtensions
def calculate_ip
# Set by the Rack web server, this is a single value.
remote_addr = ips_from(@req.remote_addr).last
remote_addr = sanitize_ips(ips_from(@req.remote_addr)).last
# Could be a CSV list and/or repeated headers that were concatenated.
client_ips = ips_from(@req.client_ip).reverse!
forwarded_ips = ips_from(@req.x_forwarded_for).reverse!
client_ips = sanitize_ips(ips_from(@req.client_ip)).reverse!
forwarded_ips = sanitize_ips(@req.forwarded_for || []).reverse!
# `Client-Ip` and `X-Forwarded-For` should not, generally, both be set. If they
# are both set, it means that either: