summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-08-13 09:34:11 -0500
committerDan McGee <dan@archlinux.org>2012-08-13 21:24:40 -0500
commit3cb16e4784f492c50555e879ea6b07fd898b1c3d (patch)
tree631b0a406183ad28e6051507fbcc31d88f0ec404
parentaa7f51e6bd80fded21fabf3135ebe78ff32b24c7 (diff)
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>
-rw-r--r--packages/views/flag.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/views/flag.py b/packages/views/flag.py
index 16f5f202..33cec006 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,