I've run into a problem where a Match CAPTCHA expects a specific response but does not allow for enough characters in the input field. For example:

10 - ? = 0

I go to enter 10 for the ?, and am only allowed 1 character in the input field.

Digging into the problem, it's actually a really easy fix. Open up match_captcha.challenge.inc, and on line 81 (create a newline before the return), add:

$form_item['form']['captcha_response']['#maxlength'] = strlen($form_item['solution']);

Without this fix, you will only be allowed to enter as many characters long as the result (right side of the =, see line 63 in the same file). This change will allow you to properly enter up to as many characters as the solution requires.

Comments

soxofaan’s picture

Status: Active » Fixed

Good catch!
thanks

fixed by http://drupal.org/cvs?commit=230290

note: I solved it slightly different:

 '#maxlength' => max(strlen("$result"), strlen("$x"), strlen("$y")),
soxofaan’s picture

Priority: Normal » Minor
Status: Fixed » Needs work

still some refining needed.

Just observed minor very low frequency problem with admin mode:
* captcha on create page node form and admin mode enabled
* go to create page node form (with solution = 10)
* preview
* form gets rebuilt with likely a solution different from 10
* drupal complains that the default value is larger than the maxlength permits (or something like that)

fix: maxlength should be the maximum length of all possible values in the enabled range, not the maximum of $x, $y and $result.

soxofaan’s picture

Status: Needs work » Fixed
soxofaan’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.