Illegal Username Characters

Need help with the Administration of your Joomla! site? Pop your questions in here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Illegal Username Characters

Post by jgilhousen » Sat Dec 24, 2005 7:39 pm

Anyone know of an easy way to permit usernames with characters that are illegal by default for Joomla! usernames, specifically the hyphen?

User avatar
benedikt
Joomla! Explorer
Joomla! Explorer
Posts: 346
Joined: Mon Aug 22, 2005 2:29 pm
Location: Gent - Belgium

Re: Illegal Username Characters

Post by benedikt » Sun Dec 25, 2005 1:28 am

I don't know enough php to answer that, so I can't provide an easy answer ;)
Maybe not much of a help, but I 'd start with taking a look at mod_login.

But there is probably a very good reason why such characters are illegal, most likely to avoid malicious code injection.
Furthermore, many people consider it good practice NOT to hack/modifie the core code. It can make upgrading a real pain.

So, my humble advice would be to encourage your users to use names that don't have these illegal characters.

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Sun Dec 25, 2005 4:17 am

I understand that such a feature was probably instituted for a valid reason, but I believe I have equally valid reasons to make an exception.  I don't much relish the notion of mucking about the code, and keeping change logs to assist in upgrades, but there are times when it is necessary, and this is probably just such a time.  I won't bore you with the reasons.

If I do end up taking a monkey wrench to Joomla! nuts and bolts, some guidance narrowing it down would be of great value.  I'll see what I can find in mod_login.

Thanks & Merry Christmas.

rocky222
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Fri Sep 16, 2005 6:08 pm

Re: Illegal Username Characters

Post by rocky222 » Thu Jan 12, 2006 9:42 am

I had the same issue as I imported 5000 forum users into Joomla, and a lot of them had usernames with special characters. So I needed to find a way to allow these characters. With some help from other Joomla members, I think I got it right.

Now, I have Community builder installed as well, and even though I thought I had the problem taken care of, some of my users are still complaining they are not able to update their profiles.

Anyway, here's the hack...

Look in /includes/joomla.php and find this block of code

Code: Select all

if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", $this->username) || strlen( $this->username ) < 3) {
$this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 );
return false;
}

Code: Select all

[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]
are the characters that are not allowed in usernames. What you want to do is to remove the characters that you want to allow. So if you want to allow the hyphen, this is the code to use:

Code: Select all

if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+]", $this->username) || strlen( $this->username ) < 3) {
$this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 );
return false;
}
I'd really appreciate some input from the devs on this. I'm not sure I have done this the right way... A backend option on which characters not to allow in a username would be awesome.

User avatar
louis.landry
Joomla! Ace
Joomla! Ace
Posts: 1380
Joined: Wed Aug 17, 2005 11:03 pm
Location: San Jose, California
Contact:

Re: Illegal Username Characters

Post by louis.landry » Thu Jan 12, 2006 10:00 am

What you did is correct... and a list of banned characters is not a bad idea.... I will keep you posted.

Louis
Joomla Platform Maintainer
A hacker does for love what others would not do for money.

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Thu Jan 12, 2006 6:44 pm

Thanks for pointing me in the right direction.  I kept overlooking it on my own.

I understood the need for a banned characters list, but wish it were more easily configurable, for those instances when an exception should be made.  Life is full of exceptions. ;)

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Thu Jan 12, 2006 7:20 pm

Argh!  I posted too soon -- before actually doing the edit.

After removing the hyphen and separating backslash preceding it, I logged into the front end, went to Your Details, and tried to insert a hyphen into my username.  Result: Error message for invalid username.

So, I logged out, and logged into back end as admin, and tried to do the same change in User Management.  No go there, either.

Do I need to do a textsearch of every file to find all instances of that array?

John-Mark +

anneeasterling
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Thu Mar 09, 2006 4:42 pm
Contact:

Re: Illegal Username Characters

Post by anneeasterling » Wed Apr 05, 2006 9:14 pm

John-Mark,

Did you ever figure out how to make this work? I am in the same boat -- need to import an existing list and my board is QUITE insistent that the usernames be our members' email addresses. ANDDDD many of them have hyphens.

Any assistance from anyone will be greatly appreciated. (And yes, I understand why there are the restrictions on special characters, but this is essential.)

Thank you,
Anne
Author, EZ Fun Guide to Walt Disney World
My first Joomla site: http://www.ez-wdw.com

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Wed Apr 05, 2006 10:07 pm

Anne,

Nope.  I spent several days trying, and never could get it to fly.  I decided I need to get further along in php tutorials before taking another stab at it.

The limitation is a real problem for us, because ours is a family history and genealogy site, so we strongly encourage people to use their real names, often (like mine) including a hyphen.

I would really appreciate it if one of the php gurus in the Joomla! community could crack it for us.

J-M

anneeasterling
Joomla! Apprentice
Joomla! Apprentice
Posts: 26
Joined: Thu Mar 09, 2006 4:42 pm
Contact:

Re: Illegal Username Characters

Post by anneeasterling » Wed Apr 05, 2006 10:55 pm

J-M!!!!!

I did it!!! I have Community Building installed. I had edited several files using your edit -- basically taking out the "|\-". Then I looked at the source code and saw that it was picking up a script somewhere, so I searched some more and found this: http://forum.mamboserver.com/archive/in ... 52287.html. So I looked for a file that would do what the Mambo user_extended component does.

The key was finding components/com_comptroller/comprofile.html.php. Look for this line in a similar file:

Code: Select all

var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
and edit the |\- out.

It now works. FWIW, I could input the email address as the user name directly into the database table. But if you opened that record within Joomla, you couldn't edit anything about that record -- such as changing password -- without triggering the error message.

I still have some tweaking to do to get our members-only site working. But I am very hopeful -- It's only Wednesday and I have a goal of Friday. I might be able to make it.

Thanks for your inspiration. Let me know if it works for you.

Anne
Author, EZ Fun Guide to Walt Disney World
My first Joomla site: http://www.ez-wdw.com

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Sat Jun 24, 2006 8:10 pm

Sorry for the lag... somehow I missed your post in this topic.

Anyway, the site on which I have the need for hyphenated usernames does not have Community Builder installed, and I am reluctant to install it because of the likelihood of potential conflicts with other installed components (simpleboard and gedview).

So, there is no com_comptroller directory.

I may do a test installation with the mix of components to see if I am substituting one set of headaches for another... could be awhile, though.

J-M +

MLCrane
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jun 29, 2006 3:37 pm

Re: Illegal Username Characters

Post by MLCrane » Thu Jun 29, 2006 3:44 pm

Not sure if this will be germain any more, but I've just managed to get our new Joomla installation to accept hyphens in user names.

In the end I had to edit:-
  • includes/joomla.php
  • components/com_user/user.html.php
  • administrator/components/com_user/admin.users.html.php
And that let us build accounts where the username is an email address...

YMMV

Murray Crane
Network Administrator
GGP Systems Ltd

User avatar
jgilhousen
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Wed Dec 07, 2005 11:52 pm
Location: Oregon
Contact:

Re: Illegal Username Characters

Post by jgilhousen » Thu Jun 29, 2006 3:52 pm

Thanks, Murray.  I'll check that script and see if I can edit it to work for us.  My users that were pushing for this feature seem to have given up, or at least have quit nagging me, but I know it is still an annoyance for many, so I do want to accommodate them when I can.

Regards,

J-M +

OOPz
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Aug 04, 2007 3:14 pm

Re: Illegal Username Characters

Post by OOPz » Thu Sep 13, 2007 8:23 pm

ack... iv searched the entire site for any/all occurances of |\" and fixed everything that even looked relevent (5 total), but it still wont let me put a - in a username!?

utssace
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Fri Aug 25, 2006 10:56 pm

Re: Illegal Username Characters

Post by utssace » Sat Sep 22, 2007 2:12 pm

I am running 1.5 RC2.  I am also hoping that their is a hack available to allow special characters
in usernames.  I have been told that Joomla won't allow it but it seems that you could define a string
of acceptable or unacceptable characters that would allow a few.

My problem is I converted a phpbb2 forum to fireboard and most all users have unique characters
in their name (gaming clan site).  If I can't get this to work, I'll have to stay with my present CMS.

User avatar
C0nw0nk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 248
Joined: Tue Jun 15, 2010 1:12 am
Location: United Kingdom, London
Contact:

Re: Illegal Username Characters

Post by C0nw0nk » Sat Sep 10, 2011 11:46 pm

rocky222 wrote:I had the same issue as I imported 5000 forum users into Joomla, and a lot of them had usernames with special characters. So I needed to find a way to allow these characters. With some help from other Joomla members, I think I got it right.

Now, I have Community builder installed as well, and even though I thought I had the problem taken care of, some of my users are still complaining they are not able to update their profiles.

Anyway, here's the hack...

Look in /includes/joomla.php and find this block of code

Code: Select all

if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", $this->username) || strlen( $this->username ) < 3) {
$this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 );
return false;
}

Code: Select all

[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]
are the characters that are not allowed in usernames. What you want to do is to remove the characters that you want to allow. So if you want to allow the hyphen, this is the code to use:

Code: Select all

if (eregi( "[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+]", $this->username) || strlen( $this->username ) < 3) {
$this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 );
return false;
}
I'd really appreciate some input from the devs on this. I'm not sure I have done this the right way... A backend option on which characters not to allow in a username would be awesome.
Thanks this is just what i was after :D

nicmehr
I've been banned!
Posts: 36
Joined: Fri Feb 04, 2011 12:19 pm

Re: Illegal Username Characters

Post by nicmehr » Sun Sep 11, 2011 3:51 am

waoooooo C0nw0nk
after 4 years you finde it :D

mido203
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Mon Jun 22, 2009 5:05 pm

Re: Illegal Username Characters

Post by mido203 » Fri Dec 23, 2016 5:26 am

Hello,
I can't find these files in Joomla 3, also can't find solution for this, any suggestions ?


Locked

Return to “Administration - 1.0.x”