summaryrefslogtreecommitdiff
path: root/sandbox/py-rest-doc/sphinx/web/application.py
diff options
context:
space:
mode:
authorblackbird <blackbird@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-05-24 18:16:01 +0000
committerblackbird <blackbird@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-05-24 18:16:01 +0000
commit1cc3c4ec99c84125b58b96cd2eec87cb6ccbdcd9 (patch)
tree246640017dbdcf5ed700f74c14e8c8f424723872 /sandbox/py-rest-doc/sphinx/web/application.py
parentba1c9c049ba68ef17154a230ffe10f37ba861d26 (diff)
downloaddocutils-1cc3c4ec99c84125b58b96cd2eec87cb6ccbdcd9.tar.gz
fixed antispam
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5128 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/py-rest-doc/sphinx/web/application.py')
-rw-r--r--sandbox/py-rest-doc/sphinx/web/application.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/sandbox/py-rest-doc/sphinx/web/application.py b/sandbox/py-rest-doc/sphinx/web/application.py
index f52d76bbb..48974201f 100644
--- a/sandbox/py-rest-doc/sphinx/web/application.py
+++ b/sandbox/py-rest-doc/sphinx/web/application.py
@@ -133,26 +133,27 @@ class DocumentationApplication(object):
title = comment_body = ''
author = req.cookies.get('author', '')
author_mail = req.cookies.get('author_mail', '')
- form_error = False
+ form_error = None
preview = None
if comments_enabled and req.method == 'POST':
- title = req.form.get('title')
- author = req.form.get('author')
- author_mail = req.form.get('author_mail')
- comment_body = req.form.get('comment_body')
+ title = req.form.get('title', '').strip()
+ author = req.form.get('author', '').strip()
+ author_mail = req.form.get('author_mail', '')
+ comment_body = req.form.get('comment_body', '')
fields = (title, author, author_mail, comment_body)
if req.form.get('preview'):
preview = Comment(page_id, title, author, author_mail,
comment_body)
elif req.form.get('homepage') or self.antispam.is_spam(fields):
- return Response('Rejected Spam', mimetype='text/plain', status=403)
+ form_error = 'Your text contains blocked URLs or words.'
else:
- form_error = not all(fields) or \
- _mail_re.search(author_mail) is not None
-
- if not form_error:
+ if not all(fields):
+ form_error = 'You have to fill out all fields.'
+ elif _mail_re.search(author_mail) is None:
+ form_error = 'You have to provide a valid mail adress.'
+ else:
self.cache.pop(url, None)
comment = Comment(page_id, title, author, author_mail,
comment_body)