# HG changeset patch # User k0s # Date 1266972623 18000 # Node ID c861518b2a443209df0fa583efe68fa90a0ab5b3 # Parent 478d13061336268893df0dcd11ec86ecf85f0921 fix bug whereby forbidden characters cause issues diff -r 478d13061336 -r c861518b2a44 captchamiddleware/example.py --- a/captchamiddleware/example.py Sat Feb 06 19:00:32 2010 -0500 +++ b/captchamiddleware/example.py Tue Feb 23 19:50:23 2010 -0500 @@ -3,7 +3,7 @@ from paste.httpexceptions import HTTPExceptionHandler def example_app(environ, start_response): - return Response('
Hello, world!
')(environ, start_response) + return Response('

method=%s

Hello, world!
' % environ['REQUEST_METHOD'])(environ, start_response) def factory(global_conf, **app_conf): diff -r 478d13061336 -r c861518b2a44 captchamiddleware/middleware.py --- a/captchamiddleware/middleware.py Sat Feb 06 19:00:32 2010 -0500 +++ b/captchamiddleware/middleware.py Tue Feb 23 19:50:23 2010 -0500 @@ -39,14 +39,20 @@ f = urlopen(self.dictionary) else: f = file(self.dictionary) + + # characters skimpygimpy doesnt know about + forbidden_characters = set(["'"]) + self.words = [ i.strip() for i in f.readlines() - if len(i.strip()) > self.minimum_length ] + if (len(i.strip()) > self.minimum_length) + and not forbidden_characters.intersection(i) ] random.shuffle(self.words) def __call__(self, environ, start_response): request = Request(environ) - if request.method == 'post' and not request.remote_user: + if request.method == 'POST' and not request.remote_user: + import pdb; pdb.set_trace() pass # TODO: check CAPTCHA return LXMLMiddleware.__call__(self, environ, start_response) diff -r 478d13061336 -r c861518b2a44 setup.py --- a/setup.py Sat Feb 06 19:00:32 2010 -0500 +++ b/setup.py Tue Feb 23 19:50:23 2010 -0500 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = "0.1" +version = "0.1.1" setup(name='CAPTCHAmiddleware', version=version,