mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-08 22:07:55 +00:00
web/postkey/views.py: implement base64 hash validation
This commit is contained in:
parent
a46dc18731
commit
329ad74cbe
@ -40,6 +40,15 @@ class AddForm(ModelForm):
|
||||
if re.search(r'(^|\.)(proxy|router|console)$', namepart):
|
||||
raise forms.ValidationError('Trying to use reserved hostname')
|
||||
return data
|
||||
def clean_b64hash(self):
|
||||
data = self.cleaned_data['b64hash']
|
||||
# Minimum key length 516 bytes
|
||||
if len(data) < 516:
|
||||
raise forms.ValidationError('Specified base64 hash are less than 516 bytes')
|
||||
# base64-i2p
|
||||
if re.match(r'[a-zA-Z0-9\-~]+AAAA$', data) == None:
|
||||
raise forms.ValidationError('Invalid base64 hash')
|
||||
return data
|
||||
|
||||
def index(request):
|
||||
if request.method == 'POST':
|
||||
|
Loading…
Reference in New Issue
Block a user