changeset 2:c861518b2a44

fix bug whereby forbidden characters cause issues
author k0s <k0scist@gmail.com>
date Tue, 23 Feb 2010 19:50:23 -0500
parents 478d13061336
children b0ef5452a740
files captchamiddleware/example.py captchamiddleware/middleware.py setup.py
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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('<html><body><form method="post">Hello, world!<input type="submit"/></form></body></html>')(environ, start_response)
+    return Response('<html><body><p>method=%s</p><form method="post">Hello, world!<input type="submit"/></form></body></html>' % environ['REQUEST_METHOD'])(environ, start_response)
 
 
 def factory(global_conf, **app_conf):
--- 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)
--- 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,