PDA

View Full Version : apostrophe in their usernames


Kihon Kata
01-20-2007, 01:04 AM
How can I easily prevent users from registering with an apostrophe in their usernames?

Thanks in advance!

Why does no one reply to threads like this? I am posting on the wrong site?

Attilitus
01-20-2007, 09:53 PM
You merely need to go into vbulletin settings and add apostrophes to the banned characters for usernames. :)

Kihon Kata
01-20-2007, 10:38 PM
You merely need to go into vbulletin settings and add apostrophes to the banned characters for usernames. :)
and where do I find that? I don't see a Banned Character section

Attilitus
01-20-2007, 11:03 PM
Go to vbulletin options, then to User Registration Options.

Then find Username Regular Expressions. Click on the "help button" in order to view the REGEX codes which allow certain characters.

I will go ahead and paste the contents of the helpbutton.

^[A-Z]+$ - Characters from A-Z only
^[A-Z ]+$ - Characters from A-Z including space
^[A-Z0-9 ]+$ - Alphanumeric characters including space
^[\x20-\x7E]+$ - ASCII characters from 32-127


So just choose the allowed characters that you want in usernames, and paste that into the Username Regular Expressions option field in vbulletin options under User Registration Options.

Kihon Kata
01-21-2007, 01:42 AM
Go to vbulletin options, then to User Registration Options.

Then find Username Regular Expressions. Click on the "help button" in order to view the REGEX codes which allow certain characters.

I will go ahead and paste the contents of the helpbutton.

^[A-Z]+$ - Characters from A-Z only
^[A-Z ]+$ - Characters from A-Z including space
^[A-Z0-9 ]+$ - Alphanumeric characters including space
^[\x20-\x7E]+$ - ASCII characters from 32-127


So just choose the allowed characters that you want in usernames, and paste that into the Username Regular Expressions option field in vbulletin options under User Registration Options.
Thanks, but I don't get it. How would one allow everything except apostraphes?

Attilitus
01-21-2007, 02:00 AM
You would be best choosing one of the options.

^[A-Z0-9 ]+$

Would allow all letters, numbers, and spaces, while disallowing all other characters.

Is there a specific reason why you only want to ban apostrophes?

Merriweather
03-04-2007, 10:39 PM
If you try to register with an apostrophe, you get a DB error because it breaks the MySQL query. You also can't administer a user account with an apostrophe in it. vB should ban it by default, or take this into account, but apparently they don't.

I used the regex to only allow letters, numbers and spaces, but the problem now is that if you use something other than those, it doesn't tell you that's why you get an error, it says "that username already exists", which isn't true.

Kirk Y
03-04-2007, 10:50 PM
It is... all vBulletin input fields are cleaned to prevent such things.

Cap'n Steve
03-05-2007, 12:56 AM
^--- I'm pretty sure apostrophes work in usernames.

If you try to register with an apostrophe, you get a DB error because it breaks the MySQL query. You also can't administer a user account with an apostrophe in it. vB should ban it by default, or take this into account, but apparently they don't.

It sounds like you have a poorly made mod installed.

Adrian Schneider
03-05-2007, 01:13 AM
Apostrophes should be OK. You should rarely have to deal with the username though - that is what the userid column is for.

Anyway, to escape it: $username $db->escape_string($username);

Marco van Herwaarden
03-05-2007, 05:23 AM
If you try to register with an apostrophe, you get a DB error because it breaks the MySQL query. You also can't administer a user account with an apostrophe in it. vB should ban it by default, or take this into account, but apparently they don't.

I used the regex to only allow letters, numbers and spaces, but the problem now is that if you use something other than those, it doesn't tell you that's why you get an error, it says "that username already exists", which isn't true.
If you get a SQL-error on a username with an apostrophe, then i would quickly uninstall my modifications, as you have installed a modification that is potentially open for SQL-injections.

Default vBulletin works fine with any username.