10000 Solves #6045 by not throwing an exception when an invalid ip address … · django-cms/django-cms@dac7fa7 · GitHub
[go: up one dir, main page]

Skip to content

Commit dac7fa7

Browse files
Andras Gyomreylgandras
authored andcommitted
Solves #6045 by not throwing an exception when an invalid ip address is specified
1 parent 92561a7 commit dac7fa7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cms/middleware/toolbar.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"""
33
Edit Toolbar middleware
44
"""
5+
from django import forms
56
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE
7+
from django.core.exceptions import ValidationError
68
from django.core.urlresolvers import resolve
79
from django.http import HttpResponse
810

@@ -27,8 +29,13 @@ def is_cms_request(self, request):
2729

2830
if internal_ips:
2931
client_ip = get_request_ip(request)
30-
if client_ip not in internal_ips:
32+
try:
33+
client_ip = forms.GenericIPAddressField().clean(client_ip)
34+
except ValidationError:
3135
return False
36+
else:
37+
if client_ip not in internal_ips:
38+
return False
3239

3340
if not toolbar_hide:
3441
return True

0 commit comments

Comments
 (0)
0