From b1cebdbd990c8aa702bec34a73b31f44821882ad Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 2 Dec 2018 17:45:48 +0100 Subject: [PATCH] Fix #582 -- Improve validation of organizer domains --- src/pretix/control/forms/organizer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pretix/control/forms/organizer.py b/src/pretix/control/forms/organizer.py index 91aa00455f..46b776ba3c 100644 --- a/src/pretix/control/forms/organizer.py +++ b/src/pretix/control/forms/organizer.py @@ -1,3 +1,5 @@ +from urllib.parse import urlparse + from django import forms from django.conf import settings from django.core.exceptions import ValidationError @@ -80,6 +82,19 @@ class OrganizerUpdateForm(OrganizerForm): help_text=_('You need to configure the custom domain in the webserver beforehand.') ) + def clean_domain(self): + d = self.cleaned_data['domain'] + if d: + if d == urlparse(settings.SITE_URL).hostname: + raise ValidationError( + _('You cannot choose the base domain of this installation.') + ) + if KnownDomain.objects.filter(domainname=d).exclude(organizer=self.instance.pk).exists(): + raise ValidationError( + _('This domain is already in use for a different organizer.') + ) + return d + def clean_slug(self): if self.change_slug: return self.cleaned_data['slug']