When the "Use only uppercase" checkbox is checked, and a user tries to submit uppercase text the form does not validate, if they submit lowercase text it will. After looking in the captcha.inc file, i noticed this around line 408 :

  //everytime we create a new code, we write it to session
  $_SESSION['captcha'] = drupal_strtolower($string);

  if(variable_get('textimage_captcha_use_only_upper',0)) {
    $string = drupal_strtoupper($string); 
  }

  return $string;

From what i can tell of this logic, it first sets the $_SESSION var to lower, runs the upper case if that is set, but doesn't change the $_SESSION var to upper. By adding $_SESSION['captcha'] = drupal_strtoupper($string); below $string = drupal_strtoupper($string); it appears to work correctly. Did have one problem where the initial preview of a comment would not validate, but after that it would, i'm guessing it was just a cashed string. Appeared to disappear after unchecking and then rechecking the "Use only uppercase" (Need other people to verify).

  //everytime we create a new code, we write it to session
  $_SESSION['captcha'] = drupal_strtolower($string);

  if(variable_get('textimage_captcha_use_only_upper',0)) {
    $string = drupal_strtoupper($string);
    $_SESSION['captcha'] = drupal_strtoupper($string); //Convert session var to upper!
  }

  return $string;

I think this was supposed to be solved by the setting in the preset that would convert the text input, but that does not appear to affect the input at all, nor could i find a function that handled it, guess that part isn't finished?

Comments

codewatson’s picture

Just wanted to follow up that it seems to be working fine now, have had it running for about a week now with no spam and regular users have been able to post without problems, you can check it out at http://www.virtualpoetryslam.net (comments are not immediately posted due to some abusive comments (non spam) that happened, but at least you can see that it does get submitted and what not.)

Again if anyone could confirm this it would be helpful for others i think.

deciphered’s picture

Status: Active » Closed (fixed)