? .buildpath
? .bzr
? .cvsignore
? .project
? .settings
? captcha-2.2.XSS_.patch
? image_captcha/.DS_Store
? image_captcha/fonts/.DS_Store
? image_captcha/fonts/.gitignore
? image_captcha/fonts/1456Gutenberg.TTF
? image_captcha/fonts/Army.ttf
? image_captcha/fonts/BABYK___.TTF
? image_captcha/fonts/actionj.ttf
? image_captcha/fonts/dropacha.ttf
? image_captcha/fonts/skinck.ttf
? image_captcha/fonts/subeve.ttf
? image_captcha/fonts/tiza.ttf
? image_captcha/fonts/Tesox/.DS_Store
? tests/.DS_Store
? translations/.DS_Store
? translations/captcha-6.x-2.0-nl.po
Index: captcha.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.module,v
retrieving revision 1.103.2.9
diff -u -b -u -p -r1.103.2.9 captcha.module
--- captcha.module	5 Jul 2010 21:37:21 -0000	1.103.2.9
+++ captcha.module	18 Oct 2010 21:06:07 -0000
@@ -480,9 +480,17 @@ function _captcha_get_posted_captcha_inf
       $post_data = array();
     }
     // Get the posted form_id and CAPTCHA session ID.
-    $posted_form_id = isset($post_data['form_id']) ? $post_data['form_id'] : NULL;
-    $posted_captcha_sid = isset($post_data['captcha_sid']) ? (int) $post_data['captcha_sid'] : NULL;
-    $posted_captcha_token = isset($post_data['captcha_token']) ? (string) $post_data['captcha_token'] : NULL;
+    // Because we possibly use raw post data here,
+    // we should be extra cautious and filter this data.
+    $posted_form_id = isset($post_data['form_id']) ?
+      preg_replace("/[^a-z0-9_]/", "", (string) $post_data['form_id'])
+      : NULL;
+    $posted_captcha_sid = isset($post_data['captcha_sid']) ?
+      (int) $post_data['captcha_sid']
+      : NULL;
+    $posted_captcha_token = isset($post_data['captcha_token']) ?
+      preg_replace("/[^a-zA-Z0-9]/", "", (string) $post_data['captcha_token'])
+      : NULL;
 
     // Check if the posted CAPTCHA token is valid for the posted CAPTCHA
     // session ID. Note that we could just check the validity of the CAPTCHA
