Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#132 closed defect (fixed)

REMOTE_ADDR not in WSGI-environ

Reported by: anonymous Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords: wsgi
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The WSGI-spec does not promise the presence of 'REMOTE_ADDR' in environ, but DjangoContext reads it unconditionally when checking if it is in INTERNAL_IPS.

Here is a short patch to fix this, by using .get instead of [].

Index: django/core/extensions.py
===================================================================
--- django/core/extensions.py   (revision 247)
+++ django/core/extensions.py   (working copy)
@@ -13,7 +13,7 @@
         self['user'] = request.user
         self['messages'] = request.user.get_and_delete_messages()
         self['perms'] = PermWrapper(request.user)
-        if DEBUG and request.META['REMOTE_ADDR'] in INTERNAL_IPS:
+        if DEBUG and request.META.get('REMOTE_ADDR') in INTERNAL_IPS:
             self['debug'] = True
             from django.core import db
             self['sql_queries'] = db.db.queries

Change History (1)

comment:1 Changed 10 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [270]) Fixed #132 -- thanks anonymous user

Note: See TracTickets for help on using tickets.
Back to Top