mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-09 06:18:05 +00:00
web/lib/validation.py: new b64 length check
b64 hash shouldn't be longer than 616 bytes. We already have length limit in database model, but this way we can provide our custom error message.
This commit is contained in:
parent
bc3118ab44
commit
2b535dbf2b
@ -48,6 +48,8 @@ def validate_b64hash(data, check_uniq=True):
|
||||
# Minimum key length 516 bytes
|
||||
if length < 516:
|
||||
raise forms.ValidationError('Specified base64 hash are less than 516 bytes')
|
||||
if length > 616:
|
||||
raise forms.ValidationError('Specified base64 hash are bigger than 616 bytes')
|
||||
# keys with cert may ends with anything, so check is relaxed
|
||||
if length > 516 and re.match(r'[a-zA-Z0-9\-~]+$', data) == None:
|
||||
raise forms.ValidationError('Invalid characters in base64 hash')
|
||||
|
Loading…
Reference in New Issue
Block a user