diff options
author | Dan McGee <dan@archlinux.org> | 2012-08-13 16:34:11 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-08-14 04:24:40 +0200 |
commit | 3cb16e4784f492c50555e879ea6b07fd898b1c3d (patch) | |
tree | 631b0a406183ad28e6051507fbcc31d88f0ec404 /packages/views | |
parent | aa7f51e6bd80fded21fabf3135ebe78ff32b24c7 (diff) | |
download | archweb-3cb16e4784f492c50555e879ea6b07fd898b1c3d.tar.gz archweb-3cb16e4784f492c50555e879ea6b07fd898b1c3d.tar.xz |
Attempt to screen for useless out-of-date messages
Things like ' ', '-', '.', etc. will no longer be accepted in this
field.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views')
-rw-r--r-- | packages/views/flag.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/views/flag.py b/packages/views/flag.py index 16f5f20..33cec00 100644 --- a/packages/views/flag.py +++ b/packages/views/flag.py @@ -1,3 +1,5 @@ +import re + from django import forms from django.conf import settings from django.contrib.auth.decorators import permission_required @@ -30,6 +32,15 @@ class FlagForm(forms.Form): if auth: del self.fields['email'] + def clean_message(self): + data = self.cleaned_data['message'] + # make sure the message isn't garbage (only punctuation or whitespace) + # and ensure a certain minimum length + if re.match(r'^[^0-9A-Za-z]+$', data) or len(data) < 3: + raise forms.ValidationError( + "Enter a valid and useful out-of-date message.") + return data + @cache_page(3600) def flaghelp(request): @@ -78,7 +89,6 @@ def flag(request, name, repo, arch): current_time = now() pkgs.update(flag_date=current_time) # store our flag request - # TODO flag_request = FlagRequest(created=current_time, user_email=email, message=message, ip_address=ip_addr, pkgbase=pkg.pkgbase, |