Index: captcha.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/captcha/captcha.module,v
retrieving revision 1.100
diff -u -r1.100 captcha.module
--- captcha.module	20 Sep 2009 10:57:07 -0000	1.100
+++ captcha.module	1 Oct 2009 09:20:34 -0000
@@ -197,9 +197,28 @@
   // were used here, but those entry are not available in node preview situations so
   // we use $form_state['clicked_button']['#post']['form_id'] and
   // $form_state['clicked_button']['#post']['captcha_sid'] instead.
-  $posted_form_id = (isset($form_state['clicked_button']['#post']['form_id']) ? $form_state['clicked_button']['#post']['form_id'] : NULL);
-  if ($this_form_id == $posted_form_id && isset($form_state['clicked_button']['#post']['captcha_sid'])) {
-    $captcha_sid = $form_state['clicked_button']['#post']['captcha_sid'];
+  // Internet Explorer does not create a ['clicked_button'] sub array when the form
+  // is submitted by hitting enter so we need to check ['buttons'] too
+  $posted_form_id = NULL;
+  if (isset($form_state['clicked_button']['#post']['form_id'])) {
+    $posted_form_id = $form_state['clicked_button']['#post']['form_id'];
+  }
+  else if (isset($form_state['buttons']['button']['0']['#post']['form_id'])) {
+    $posted_form_id = $form_state['buttons']['button']['0']['#post']['form_id'];
+  }
+  
+  $captcha_sid_set = FALSE;
+  if (isset($form_state['clicked_button']['#post']['captcha_sid']) || isset($form_state['buttons']['button']['0']['#post']['captcha_sid'])) {
+    $captcha_sid_set = TRUE;
+  }
+  
+  if (($this_form_id == $posted_form_id) && $captcha_sid_set) {
+    $captcha_sid = NULL;
+    if (isset($element['#post']['captcha_sid'])) { 
+      $captcha_sid = $element['#post']['captcha_sid'];
+    } else { 
+      $captcha_sid = captcha_get_posted_captcha_sid($form_state);
+    }
   } else {
     // Generate new CAPTCHA session.
     $captcha_sid = _captcha_generate_captcha_session($this_form_id, CAPTCHA_STATUS_UNSOLVED);
@@ -394,6 +413,22 @@
 }
 
 /**
+ * extract session ID from form_state structure
+ * @param $form_state the form state structure to extract the session ID from
+ * @return session ID or NULL if no session ID was found in the structure
+ */
+function captcha_get_posted_captcha_sid($form_state) {
+  if (isset($form_state['clicked_button']['#post']['captcha_sid'])) { 
+    return $form_state['clicked_button']['#post']['captcha_sid'];
+  }
+  else if (isset($form_state['buttons']['button']['0']['#post']['captcha_sid'])) {
+    return $form_state['buttons']['button']['0']['#post']['captcha_sid'];
+  }
+
+  return NULL;
+}
+
+/**
  * CAPTCHA validation handler.
  *
  * This function is placed in the main captcha.module file to make sure that
@@ -401,7 +436,6 @@
  * captcha_form_alter(), and subsequently don't include additional include
  * files).
  */
-
 function captcha_validate($element, &$form_state) {
   $captcha_info = $element['#captcha_info'];
   $form_id = $captcha_info['form_id'];
@@ -417,7 +451,9 @@
   // However, they will differ when the life span of the CAPTCHA session
   // does not equal the life span of a multipage form and then we have to
   // pick the right one.
-  $csid = $form_state['clicked_button']['#post']['captcha_sid'];
+  // Internet Explorer does not create a ['clicked_button'] sub array when the form
+  // is submitted by hitting enter so we need to check ['buttons'] too
+  $csid = captcha_get_posted_captcha_sid($form_state);
 
   $solution = db_result(db_query('SELECT solution FROM {captcha_sessions} WHERE csid = %d AND status = %d', $csid, CAPTCHA_STATUS_UNSOLVED));
 
