Browse Source

web/postkey/views.py: avoid adding non-unique hashes

pull/1/head
Hidden Z 14 years ago
parent
commit
5cb9d1943a
  1. 4
      web/postkey/views.py

4
web/postkey/views.py

@ -64,6 +64,10 @@ class AddForm(ModelForm): @@ -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):

Loading…
Cancel
Save