Django

Code

Changeset 6364

Show
Ignore:
Timestamp:
09/16/07 11:54:16 (1 year ago)
Author:
adrian
Message:

Fixed #3872 -- Fixed incorrect handling of HTTP_X_FORWARDED_FOR in SetRemoteAddrFromForwardedFor?. Thanks, Simon Willison and gregorth

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/middleware/http.py

    r5712 r6364  
    5656        else: 
    5757            # HTTP_X_FORWARDED_FOR can be a comma-separated list of IPs. 
    58             # Take just the first one. 
    59             real_ip = real_ip.split(",")[0] 
     58            # Take just the last one. 
     59            # See http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/ 
     60            real_ip = real_ip.split(",")[-1].strip() 
    6061            request.META['REMOTE_ADDR'] = real_ip