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

Skip to content

Commit 1e4a45f

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cms/middleware/toolbar.py

Lines changed: 7 additions & 2 deletions
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

@@ -12,7 +14,6 @@
1214
from cms.utils.compat.dj import MiddlewareMixin
1315
from cms.utils.request_ip_resolvers import get_request_ip_resolver
1416

15-
1617
get_request_ip = get_request_ip_resolver()
1718

1819

@@ -27,8 +28,12 @@ def is_cms_request(self, request):
2728

2829
if internal_ips:
2930
client_ip = get_request_ip(request)
30-
if client_ip not in internal_ips:
31+
try:
32+
client_ip = forms.GenericIPAddressField().clean(client_ip)
33+
except ValidationError:
3134
return False
35+
else:
36+
return client_ip in internal_ips
3237

3338
if not toolbar_hide:
3439
return True

0 commit comments

Comments
 (0)
0