bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Accents in username

(18 posts)
  • Started 2 months ago by amirhabibi
  • Latest reply from myu
  • This topic is resolved
  1. amirhabibi
    Member

    Hi! When you try to register a name containing accents, the accents are stripped.
    Any solution ?
    (0.9.0.2 & the bug is visible on this forum)

    Posted 2 months ago #
  2. This is the latest discussion I heard about the issue:
    http://bbpress.org/forums/topic/diacritic-letters-i-username-like-goran

    What is the primary language of your forum?

    Posted 2 months ago #
  3. There's also plugins like this which can easily be modified:

    http://bbpress.ru/files/plugins/CyrNickname.zip

    http://trac.bbpress.org/attachment/ticket/452/usernames_i18n_fix.php

    Posted 2 months ago #
  4. amirhabibi
    Member

    Thanks for your replies. After reading / testing your links, I found a quick working fix. Here's the plugin code :

    <?php
    /*
    Plugin Name: UTF-8 usernames
    Plugin URI:
    Description: This plugin enable utf-8 characters in usernames. Mbstring must be enabled in the php.ini.
    Author: Amir Habibi
    Author URI: http://www.residence-mixte.com/
    Version: 0.1
    */ 
    
    function sanitize_user_mbstring( $raw_username, $username, $strict = false ) {
    	$raw_username = $username;
    	$username = strip_tags($username);
    	// Kill octets
    	$username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);
    	$username = preg_replace('/&.+?;/', '', $username); // Kill entities
    
    	// Usage of 'mb_ereg_replace' instead of 'preg_replace' to preserve accents.
    	if ( $strict )
    		$username = mb_ereg_replace('|[^a-z0-9 _.\-@]|i', '', $username);
    
    	return apply_filters('sanitize_user_mbstring', $username, $raw_username, $strict);
    
    }
    
    add_action('sanitize_user', 'sanitize_user_mbstring', 0, 3);
    ?>

    To work, you must have mstring enabled in your php.ini.

    Hope this will help !

    chrishajer : our board is in french

    Posted 2 months ago #
  5. meitershaker
    Member

    great it works! but for choose a name to display on public (option in profil), a name with accents doesn't work ...

    Posted 2 months ago #
  6. amirhabibi
    Member

    meitershaker : are you talking about the 1.0 alpha ?

    Posted 2 months ago #
  7. meitershaker
    Member

    amir: yes :p

    ps: et plus précisément de la 1.0 trunk :p

    Posted 2 months ago #
  8. amirhabibi
    Member

    meitershaker: ;-) be patient!!

    Posted 2 months ago #
  9. meitershaker
    Member

    my problem is already here :( little help please :p

    Posted 2 months ago #
  10. It should be noted that using non ascii characters in bbPress is not supported and you could open yourself to a whole range of potential SQL injection threats by doing so.

    WordPress has never supported non-ascii characters in usernames and has compensated by allowing display names, bbPress 1.0 now allows display names as well for the same reason.

    Posted 1 month ago #
  11. myu
    Member

    sambauers,
    may I ask why non-ascii chars for user name can make the threats of SQL injection etc greater?

    Posted 1 month ago #
  12. @myu

    It has to do with people using different character encoding for their database tables other than UTF-8. I'm probably overstating the threat as the same problem exists on all data input and we filter it out the problem there. I was also just reviewing WordPress injection attacks of days gone by, so it was on my mind.

    In any case, the solution in the future is to change your display name after registration. Display names are UTF-8 friendly.

    Posted 1 month ago #
  13. myu
    Member

    Thanks for reply.
    Me, I personally don't mind using alphabet for username, but have to think of target audience. Got me worried a bit. :)

    I hope in the future version there's some sort of conversion mechanism for people that's already registered using utf-8 encoded username. (pretty please..)

    Posted 1 month ago #
  14. meitershaker
    Member

    @ sam
    "In any case, the solution in the future is to change your display name after registration. Display names are UTF-8 friendly. "

    doesn't work!!

    me, 2 weeks ago:
    "but for choose a name to display on public (option in profil), a name with accents doesn't work ... "

    Posted 1 month ago #
  15. @ meitershaker

    There was a bug in the display name implementation. First, update to the very latest trunk. There is a chance that you might have a user meta item for some users called 'display_name'. This will be stomping on the real setting in the user table. Use this SQL query to clear out the bad data.

    DELETE FROM bb_usermeta WHERE meta_key = 'display_name';

    Once you've updated to the latest trunk and done that, you should be able to use any UTF-8 character in display names.

    Posted 1 month ago #
  16. meitershaker
    Member

    it works! =p thanks ;)

    Posted 1 month ago #
  17. Great!

    Posted 1 month ago #
  18. myu
    Member

    Will it be possible to upgrade to 1.0 when there're people registering with utf8 usernames?
    (I'm still testing and editing with 0.9, and will need utf8 names)
    Or will it be better to use 1.0 alpha?

    Posted 1 month ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.