Usernames No Longer Allowing Punctuation

Permalink
With our user accounts, we use the naming convention firstname.lastname. This has worked great for the 630 or so users I have added so far but we recently updated to version 5.4.0.5 and now when I try to edit or add a user account I get the following error: The following errors occurred when attempting to process your request: A username may only contain letters or numbers. Also, the site has been running very slowly since the update but I have Rackspace running a slow queries test on the domain to see if they can find any issues. Thanks in advance for any help you can provide.

 
ijessup replied on at Permalink Best Answer Reply
ijessup
Old post, but I thought I'd chime in...

There is no way to fix this without modifying a core file.

~/concrete/helpers/concrete/validation.php @line 79
Original Code:
public function username($username) {
   $username = trim($username);
   if (strlen($username) < USER_USERNAME_MINIMUM) {
      return false;
   }
   if(USER_USERNAME_ALLOW_SPACES) {
      $resp = preg_match("/[^A-Za-z0-9 ]/", $username);
   } else {
      $resp = preg_match("/[^A-Za-z0-9]/", $username);
   }
   if ($resp > 0) {
      return false;
   }
   return true;
}
"Fixxed" Code:
public function username($username) {
   $username = trim($username);
   if (strlen($username) < USER_USERNAME_MINIMUM) {
      return false;
   }
   if(USER_USERNAME_ALLOW_SPACES) {
      $resp = preg_match("/[^A-Za-z0-9 .]/", $username);
   } else {
      $resp = preg_match("/[^A-Za-z0-9.]/", $username);
   }
   if ($resp > 0) {
      return false;
   }
   return true;
}
This will now allow the use of periods (.) in usernames. to add more characters just append them to the string.
jshannon replied on at Permalink Reply
jshannon
I'm not a regexp expert, but doesn't an unescaped period there mean every character, or is it different in the brackets?
ijessup replied on at Permalink Reply
ijessup
As far as I understand regex, which admittedly also isn't extensive, the above modification only allows periods. I have also tested this to make sure no other characters have been permitted.
sendiks replied on at Permalink Reply
Thanks for this. This worked great originally but today I updated to 5.4.2.1 and while the update did not write over the validation.php file, it is now giving me the same error again. Any idea what might have changed that broke this?
ijessup replied on at Permalink Reply
ijessup
Updates don't over write the concrete folder but rather go into the updates folder and create a new "core" folder for each version. This makes rolling back to an older version easier if the update borks something important.

Try copying the validation.php file I posted above and putting it in the ~/helpers/concrete folder.

This will over ride all versions/updates.
sendiks replied on at Permalink Reply
This worked! Thanks!
ijessup replied on at Permalink Reply
ijessup
No prob! You might want to mark it as the answer to avoid confusion for others, and I can rake in some of that karma. ;)