use same cleaning for the secret in (Create|Edit)DomainForm, see #338

This commit is contained in:
Thomas Waldmann 2018-09-29 00:10:01 +02:00
parent 837103fdd7
commit 7e868de697

View File

@ -63,6 +63,14 @@ class CreateDomainForm(forms.ModelForm):
class EditDomainForm(forms.ModelForm):
def clean_nameserver_update_secret(self):
secret = self.cleaned_data['nameserver_update_secret']
try:
binascii.a2b_base64(secret.encode(encoding="ascii", errors="strict"))
except (binascii.Error, UnicodeEncodeError):
raise forms.ValidationError(_("Enter a valid secret in base64 format."), code='invalid')
return secret
def clean(self):
cleaned_data = super(EditDomainForm, self).clean()