In researching username validation I discovered that the maxlength is incorrectly set to 56 when the database length is 60. This patch fixes the error by abstracting the length to a constant USER_MAX_LENGTH, which will make it easy to increase in the future and reduces the need for translation changes. I did the same for the email address.

There does not seem to be a reason for setting the username max at 56 rather than 60. The original commit that increases the maxlength from 32 to 56 is here: http://cvs.drupal.org/viewcvs/drupal/drupal/modules/user.module?r1=1.26&...

I also did a grep on modules/* and includes/* but didn't find any other references to the 56 character limit.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

forngren’s picture

Status: Needs review » Needs work

The patch works fine expect a few small issues.

1) A small offset from current head

# patch -p0 < standardize_maxlengths.patch
patching file modules/user/user.module
Hunk #6 succeeded at 1298 (offset 5 lines).
Hunk #8 succeeded at 1555 (offset 5 lines).

2) I removed the max lengths properity of the forms and submited two long strings in both fields, but it only said that the user field was to long. (Is it the FAPI that's causing this?)

ChrisKennedy’s picture

Status: Needs work » Needs review
FileSize
4.53 KB

Re-rolled against HEAD.

@forngren - yes, at the moment there is no explicit check of the password length outside of the #maxlength setting. The point of #maxlength is more to improve the UI.

ChrisKennedy’s picture

Okay I made a separate issue and patch to have fapi validate #maxlength: http://drupal.org/node/104598

forngren’s picture

Status: Needs review » Reviewed & tested by the community

Works like a charm.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)