8000 Fixed #6045 -- Validate IP address on toolbar IP check (#6046) · django-cms/django-cms@2013321 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2013321

Browse files
lgandrasczpython
authored andcommitted
Fixed #6045 -- Validate IP address on toolbar IP check (#6046)
1 parent 4d1e0a4 commit 2013321

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

810
from cms.toolbar.toolbar import CMSToolbar
@@ -26,8 +28,13 @@ def is_cms_request(self, request):
2628

2729
if internal_ips:
2830
client_ip = get_request_ip(request)
29-
if client_ip not in internal_ips:
31+
try:
32+
client_ip = forms.GenericIPAddressField().clean(client_ip)
33+
except ValidationError:
3034
return False
35+
else:
36+
if client_ip not in internal_ips:
37+
return False
3138

3239
if not toolbar_hide:
3340
return True

0 commit comments

Comments
 (0)
0