From 5cb9d1943a462b8a8f34a33f9b99547384623609 Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Wed, 13 Oct 2010 17:24:32 +0000 Subject: [PATCH] web/postkey/views.py: avoid adding non-unique hashes --- web/postkey/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/postkey/views.py b/web/postkey/views.py index 4a92a0f..6345f8b 100644 --- a/web/postkey/views.py +++ b/web/postkey/views.py @@ -64,6 +64,10 @@ class AddForm(ModelForm): # base64-i2p if re.match(r'[a-zA-Z0-9\-~]+AAAA$', data) == None: raise forms.ValidationError('Invalid base64 hash') + # Avoid adding non-unique hashes + qs = i2phost.objects.filter(b64hash=data) + if qs.exists(): + raise forms.ValidationError('Base64 hash must be unique') return data def addkey(request):