Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2007, 01:04 AM
Kihon Kata Kihon Kata is offline
 
Join Date: Nov 2003
Posts: 763
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default apostrophe in their usernames

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?
Reply With Quote
  #2  
Old 01-20-2007, 09:53 PM
Attilitus's Avatar
Attilitus Attilitus is offline
 
Join Date: Mar 2005
Posts: 393
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You merely need to go into vbulletin settings and add apostrophes to the banned characters for usernames.
Reply With Quote
  #3  
Old 01-20-2007, 10:38 PM
Kihon Kata Kihon Kata is offline
 
Join Date: Nov 2003
Posts: 763
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Attilitus View Post
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
Reply With Quote
  #4  
Old 01-20-2007, 11:03 PM
Attilitus's Avatar
Attilitus Attilitus is offline
 
Join Date: Mar 2005
Posts: 393
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Code:
^[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.
Reply With Quote
  #5  
Old 01-21-2007, 01:42 AM
Kihon Kata Kihon Kata is offline
 
Join Date: Nov 2003
Posts: 763
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Attilitus View Post
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.
Code:
^[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?
Reply With Quote
  #6  
Old 01-21-2007, 02:00 AM
Attilitus's Avatar
Attilitus Attilitus is offline
 
Join Date: Mar 2005
Posts: 393
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 03-04-2007, 10:39 PM
Merriweather Merriweather is offline
 
Join Date: Nov 2006
Posts: 389
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 03-04-2007, 10:50 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is... all vBulletin input fields are cleaned to prevent such things.
Reply With Quote
  #9  
Old 03-05-2007, 12:56 AM
Cap'n Steve's Avatar
Cap'n Steve Cap'n Steve is offline
 
Join Date: Feb 2004
Location: Kalamazoo, MI, USA
Posts: 745
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^--- I'm pretty sure apostrophes work in usernames.

Quote:
Originally Posted by Merriweather View Post
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.
Reply With Quote
  #10  
Old 03-05-2007, 01:13 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
$username $db->escape_string($username); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:43 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06344 seconds
  • Memory Usage 2,264KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete