From 2b535dbf2b138f40446c8527e0ea1ff81a5469ce Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Thu, 21 Oct 2010 18:40:02 +0000 Subject: [PATCH] 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. --- web/lib/validation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/lib/validation.py b/web/lib/validation.py index 6abd6ff..d821502 100644 --- a/web/lib/validation.py +++ b/web/lib/validation.py @@ -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')