From 7e868de69716c45ae30adf6282e2a6a9431f6ce4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 29 Sep 2018 00:10:01 +0200 Subject: [PATCH] use same cleaning for the secret in (Create|Edit)DomainForm, see #338 --- nsupdate/main/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nsupdate/main/forms.py b/nsupdate/main/forms.py index 7fa6e8c..7944198 100644 --- a/nsupdate/main/forms.py +++ b/nsupdate/main/forms.py @@ -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()