changeset 4662:922550c3dd25

action.Load: added textcha feature
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 14 Mar 2009 19:32:25 +0100
parents ca61dedd6fda
children 68628fe3b091
files MoinMoin/action/Load.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/Load.py	Sat Mar 14 16:11:39 2009 +0100
+++ b/MoinMoin/action/Load.py	Sat Mar 14 19:32:25 2009 +0100
@@ -13,6 +13,7 @@
 from MoinMoin.action import ActionBase, AttachFile
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.Page import Page
+from MoinMoin.security.textcha import TextCha
 
 class Load(ActionBase):
     """ Load page action
@@ -35,6 +36,10 @@
         _ = self._
         form = self.form
         request = self.request
+        # Currently we only check TextCha for upload (this is what spammers ususally do),
+        # but it could be extended to more/all attachment write access
+        if not TextCha(request).check_answer_from_form():
+            return status, _('TextCha: Wrong answer! Go back and try again...')
 
         comment = form.get('comment', [u''])[0]
         comment = wikiutil.clean_input(comment)
@@ -88,6 +93,7 @@
 <dt>%(upload_label_comment)s</dt>
 <dd><input type="text" name="comment" size="80" maxlength="200"></dd>
 </dl>
+%(textcha)s
 <p>
 <input type="hidden" name="action" value="%(action_name)s">
 <input type="hidden" name="do" value="upload">
@@ -105,6 +111,7 @@
     'pagename': self.pagename,
     'buttons_html': buttons_html,
     'action_name': self.form_trigger,
+    'textcha': TextCha(self.request).render(),
 }
 
 def execute(pagename, request):