fixes #213, check if nameserver update secret is a valid base64 string
This commit is contained in:
parent
eccf53dcbb
commit
b81c8919ef
@ -3,6 +3,8 @@
|
||||
form definitions (which fields are available, order, autofocus, ...)
|
||||
"""
|
||||
|
||||
import binascii
|
||||
|
||||
from django import forms
|
||||
|
||||
from .models import Host, RelatedHost, Domain, ServiceUpdaterHostConfig
|
||||
@ -42,6 +44,14 @@ class EditRelatedHostForm(forms.ModelForm):
|
||||
|
||||
|
||||
class CreateDomainForm(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
|
||||
|
||||
class Meta(object):
|
||||
model = Domain
|
||||
fields = ['name', 'nameserver_ip', 'nameserver2_ip', 'nameserver_update_algorithm',
|
||||
|
Loading…
x
Reference in New Issue
Block a user