Browse Source

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.
pull/1/head
Hidden Z 14 years ago
parent
commit
2b535dbf2b
  1. 2
      web/lib/validation.py

2
web/lib/validation.py

@ -48,6 +48,8 @@ def validate_b64hash(data, check_uniq=True): @@ -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…
Cancel
Save