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

Skip to content

Solves #6045 by not throwing an exception when an invalid ip address … #6046

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

Merged
merged 1 commit into from
Oct 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Solves #6045 by not throwing an exception when an invalid ip address …
…is specified
  • Loading branch information
Andras Gyomrey authored and lgandras committed Sep 9, 2017
commit dac7fa77895496b274139cc1b329dc36a2fde19e
9 changes: 8 additions & 1 deletion cms/middleware/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"""
Edit Toolbar middleware
"""
from django import forms
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE
from django.core.exceptions import ValidationError
from django.core.urlresolvers import resolve
from django.http import HttpResponse

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

if internal_ips:
client_ip = get_request_ip(request)
if client_ip not in internal_ips:
try:
client_ip = forms.GenericIPAddressField().clean(client_ip)
except ValidationError:
return False
else:
if client_ip not in internal_ips:
return False

if not toolbar_hide:
return True
Expand Down
0