diff captchamiddleware/middleware.py @ 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
line wrap: on
line diff
--- 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)