Index: tracpaste/htdocs/style.css =================================================================== --- tracpaste/htdocs/style.css (revision 374) +++ tracpaste/htdocs/style.css (working copy) @@ -47,3 +47,7 @@ textarea { width: 100%; } + +div.turingtest { + display: none; +} \ No newline at end of file Index: tracpaste/__init__.py =================================================================== --- tracpaste/__init__.py (revision 374) +++ tracpaste/__init__.py (working copy) @@ -4,7 +4,7 @@ """ import re from trac.core import * -from trac.web import HTTPNotFound +from trac.web import HTTPNotFound, HTTPForbidden from trac.env import IEnvironmentSetupParticipant from trac.perm import IPermissionRequestor from trac.config import BoolOption, IntOption, ListOption, Option @@ -53,6 +53,14 @@ list of MIME types to filter (these are glob patterns, i.e. \"*\" can be used as a wild card).""") + turing_test = BoolOption('pastebin', 'turing_test', 'true', + """If enabled, the form for new pastes will be expanded by an additional + field. If anything is entered here, the paste will not be accepted. + The idea behind it is that spam bots usually fill every form field. + Most browsers won't display the field (as long as they support CSS), + and those that do will also display a warning for legitimate + users.""") + # IEnvironmentSetupParticipant def environment_created(self): self._upgrade_db(self.env.get_db_cnx()) @@ -113,6 +121,9 @@ # new post if req.args['new_paste']: + if 'turing' in req.args and req.args.get('turing') != '': + raise HTTPForbidden('Go away, spammer!') + title = req.args.get('title', 'untitled') author = req.args.get('author', req.authname) mimetype = req.args.get('mimetype', 'text/plain') @@ -179,6 +190,7 @@ data = { 'mode': 'new', 'replyto': replyto, + 'turing': self.turing_test, 'mimetypes': self._get_mimetypes(), 'mimetype': mimetype, 'title': title, Index: tracpaste/templates/pastebin.html =================================================================== --- tracpaste/templates/pastebin.html (revision 374) +++ tracpaste/templates/pastebin.html (working copy) @@ -45,6 +45,18 @@ +
+ Leave the above field empty. It is meant as turing test for spam bots - + if it gets filled, the paste will not be accepted. +
+