-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fix ident format when using HTTP_X_FORWARDED_FOR #2401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If NUM_PROXIES setting is set to None, HTTP_X_FORWARDED_FOR might be used as is, which might contain spaces and cause errors on cache backends like memcached.
ident = request.META.get('REMOTE_ADDR') | ||
else: | ||
ident = ''.join(ident.split()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why those were removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xordoquy they weren't being used at all.
Note: This happens in both v2 and v3. |
Looks okay to me - anyone else want to second it? |
@@ -35,7 +35,7 @@ def get_ident(self, request): | |||
client_addr = addrs[-min(num_proxies, len(xff))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in #2400 (comment), this should be len(addrs)
instead of len(xff)
.
This should be good to go. Thanks for the reviews. |
Fix ident format when using HTTP_X_FORWARDED_FOR
@tomchristie not sure if it's worth fixing this in 2.4 as well. Seems to be workable around easily. Let's see if it comes up again. |
The general idea was to drop the 2.4 support since our time is limited. |
I'd have no great argument if somebody wanted to spend their time on that, but I don't think it's a good effort/reward myself, so unless someone wants to get really proactive with making a further 2.4.x release happen then it's a no from me. |
👍 |
If
NUM_PROXIES
setting is set to None,HTTP_X_FORWARDED_FOR
might be used as is, whichmight contain spaces and cause errors on cache backends like memcached. Ref #2400