option for case insensitive validation of image CAPTCHA

soxofaan - September 30, 2007 - 11:38
Project:CAPTCHA
Version:6.x-1.x-dev
Component:Image Captcha (image_captcha)
Category:feature request
Priority:normal
Assigned:soxofaan
Status:closed
Description

In some situations it could be handy to make the validation of the image CAPTCHA case insensitive (e.g. when the used font has little differences between the upper and lower case characters or when it's too difficult to explain to your target audience what upper/lower case is)

#1

Rob Loach - October 2, 2007 - 19:31

You can head over to admin/user/captcha/image_captcha and change the "Characters to use in the code" to have only uppercase, or lowercase letters. It might be a good idea, however, to add an option to make the validation case insensitive.

#2

DaveGV - May 7, 2008 - 01:16

I am adding a potential patch to apply case insensitivity to the current dev code base. Updates are in captcha.pages.inc and image_captcha.admin.inc Strongly suggest review! This is my first patch.

AttachmentSize
captchaCaseInsensitive.txt 1.29 KB

#3

soxofaan - May 7, 2008 - 07:32
Status:active» needs work

Hi Dave,

Thanks for your patch. Some remarks:

  • patches should be in unified format, you should add the option -up to your cvs diff command (see under readability in http://drupal.org/patch/create). It's also common to add the extension .patch instead of .txt, but that's a detail.
  • you have both variable_get('captcha_ignore_case_sensitivity', TRUE) and variable_get('captcha_ignore_case_sensitivity', FALSE). There should be only one default for settings variable, and it should be FALSE in this case so that the feature is disabled by default.
  • You marked this feature for CAPTCHA 5.x-3.x-dev, but it seems that the you patched the version from HEAD, which is CAPTCHA 6.x-2.x-dev. For CAPTCHA 5.x-3.x-dev you should checkout the branch DRUPAL-5--3 (add the option -r DRUPAL-5--3 to your cvs checkout).
  • The feature spans two modules captcha.module and image_captcha.module, but note that there are many other CAPTCHA types (e.g. see http://drupal.org/project/captcha_pack), so there could be conflicts. It's better to isolate the feature to one module.
    • The simplest option is to isolate it in image_captcha and implement a preprocess hook in image_captcha_captcha(). See the CAPTCHA api docs under "=== Optional: preprocess the response ===" for more information
    • A lot more difficult is to add the feature in captcha.module and to make it available to all CAPTCHA types in a generic way.

    I would pick the first option for now

  • I think "unsophisticated users" is a bit disrespectful to all the grandma's in the world ;) I would make the description more neutral.
  • Something to keep in mind for this feature is that it also should work for non Latin languages (e.g. Hebrew, Greek, ...). I don't know if strtoupper/strtolower handle non Latin languages well. This needs some research, but you can start with using strtoupper/strtolower anyway.

Don't be discouraged by this list, most items are minor issues.
If this is your first Drupal patch, you already did very well.
Thanks again

#4

DaveGV - May 7, 2008 - 13:22

Great feedback soxofaan - thank-you very much! I'll review the fixes and get a new patch uploaded in a few days. I have other obligations that will keep me busy for a day or two, but should find some time to make another attempt soon.

One question - would you suggest that I create a separate feature request for the 6.X update, or revise this entry for 6.X? I think I'd like to stay on one version for now.

Thanks,
Dave

#5

soxofaan - May 7, 2008 - 18:25

no problem, there is no rush

typically a feature is implemented in one branch and after it's finished, it gets ported to the other maintained branches. No need for a separate issue, there is a "patch (to be ported)" status

#6

DaveGV - May 15, 2008 - 02:05
Version:5.x-3.x-dev» 6.x-2.x-dev

Here is my second attempt. Hopefully this one is pretty close for the HEAD code base. Once I get this one figured out, perhaps I'll go back to the current 6.X. I'm running this version on my site now - no badness so far.

AttachmentSize
NoCase14MAY2008.patch 3.75 KB

#7

soxofaan - May 17, 2008 - 13:58
Version:6.x-2.x-dev» 6.x-1.x-dev
Assigned to:Anonymous» soxofaan
Status:needs work» patch (to be ported)

Getting closer.

Some remarks however ;)

  • you use the variable captcha_ignore_case_sensitivity to store the option, it's better to use the prefix image_captcha_ for image captcha settings
  • I think the expression "Ignore the user's case sensitivity in their answer" is a bit weird. I think the module has to be case sensitive or case insensitive, it's not about the users
  • in image_captcha_captcha you use "variable_get('captcha_ignore_case_sensitivity')", without a default value, this should be variable_get('captcha_ignore_case_sensitivity', FALSE)
  • you also change the code to lowercase before storing it for rendering, I think it's better to render the code as-is and only change the case in the expected answer.
  • also try to adhere to the Drupal coding standards, your patch seems to contain tabs for indentation, the proper way is 2 spaces.

in attachment you'll find an adapted version of your patch.

committed to head in http://drupal.org/cvs?commit=116700

AttachmentSize
179747_caseinsensitive01-HEAD.patch 4.55 KB

#8

scottgifford - April 9, 2009 - 21:45

I have a variation on this patch working in 5.x, any chance of a backport if I post it?

#9

soxofaan - April 10, 2009 - 08:41

at#8: if you backported it, then there is a backport ;)
be welcome to post it
I'm not very active on Drupal5 anymore, but a small patch as this one wouldn't be a problem

#10

scottgifford - April 10, 2009 - 19:57
AttachmentSize
captcha-5.x-case-insensitive.patch 3.08 KB

#11

soxofaan - April 10, 2009 - 21:36
Status:patch (to be ported)» fixed

http://drupal.org/cvs?commit=195408

#12

scottgifford - April 14, 2009 - 04:39

The backported fix seems to work for me, thanks!

#13

System Message - April 28, 2009 - 04:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.