summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefaan Lippens2011-12-24 00:48:59 (GMT)
committer Stefaan Lippens2011-12-24 01:19:11 (GMT)
commitef22105dbd22381f47d496a48f7065c01592f0f0 (patch)
tree5339b80ad549fc7ff642e7c5e36f22c9a7ebc7a3
parent2591d2de7a8cb359b02e2ef4b830083ce46c69c9 (diff)
Issue #1024370: only use $form_state['captcha_info'] cache after submission (e.g. comment/node previewing)
On some forms $form_state can be cached across requests, and the CAPTCHA info in there should not be used during form building before submitting.
-rw-r--r--captcha.module7
1 files changed, 4 insertions, 3 deletions
diff --git a/captcha.module b/captcha.module
index b157489..4101e39 100644
--- a/captcha.module
+++ b/captcha.module
@@ -481,9 +481,10 @@ function captcha_validate_case_insensitive_ignore_spaces($solution, $response) {
* if the values could not be found, e.g. for a fresh form).
*/
function _captcha_get_posted_captcha_info($element, $form_state, $this_form_id) {
- if (isset($form_state['captcha_info'])) {
- // We already determined the posted form ID and CAPTCHA session ID
- // for this form, so we reuse this info
+ if ($form_state['submitted'] && isset($form_state['captcha_info'])) {
+ // We are handling (or rebuilding) an already submitted form,
+ // so we already determined the posted form ID and CAPTCHA session ID
+ // for this form (from before submitting). Reuse this info.
$posted_form_id = $form_state['captcha_info']['posted_form_id'];
$posted_captcha_sid = $form_state['captcha_info']['captcha_sid'];
}