Skip to:
Content
Pages
Categories
Search
Top
Bottom

Accents in username


  • Amir Habibi
    Member

    @amirhabibi

    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)

Viewing 17 replies - 1 through 17 (of 17 total)

  • chrishajer
    Participant

    @chrishajer

    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?


    _ck_
    Participant

    @_ck_


    Amir Habibi
    Member

    @amirhabibi

    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


    meitershaker
    Member

    @meitershaker

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


    Amir Habibi
    Member

    @amirhabibi

    meitershaker : are you talking about the 1.0 alpha ?


    meitershaker
    Member

    @meitershaker

    amir: yes :p

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


    Amir Habibi
    Member

    @amirhabibi

    meitershaker: ;-) be patient!!


    meitershaker
    Member

    @meitershaker

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


    Sam Bauers
    Participant

    @sambauers

    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.

    sambauers,

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


    Sam Bauers
    Participant

    @sambauers

    @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.

    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..)


    meitershaker
    Member

    @meitershaker

    @ 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 … “


    Sam Bauers
    Participant

    @sambauers

    @ 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.


    meitershaker
    Member

    @meitershaker

    it works! =p thanks ;)


    Sam Bauers
    Participant

    @sambauers

    Great!

    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?

Viewing 17 replies - 1 through 17 (of 17 total)

You must be logged in to reply to this topic.