• Resolved andreyguild

    (@andreyguild)


    Hello,

    I have latest versions of WordPress and w3all plugin.
    I have users in PHPBB with names like @Зеленая Ветка@ and also they you symbols like underscore and asterisk.

    They don’t get auto registered in WP.

    I’ve tried to change sanitize_user or adding plugin for Cyrillic chars in username – nothing works 100%

    At the same time single cyrillic word works or if there’s an even a single English letter in the name.

    Plz help

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author axew3

    (@axewww)

    Hello! ok … yes i think it could be a problem about this aspect that need to be re-checked … at moment the integration not work with some chars … i’ll return back here as soon with some answer!

    Plugin Author axew3

    (@axewww)

    p.s by the way, WordPress by default if i’m not wrong (and for this i say i will return over as soon with some answer) not allow the use of specific character for usernames: for example you can’t use into an username mynice’usern’ame because the char ‘ isn’t allowed as part of an username in WP. The integration require in fact as explained on procedure, that you not allow certain chars as usernames in phpBB because these are possible options in phpBB but not in WP. But as said i will return over this, that maybe i’ve misunderstand in the past.

    Plugin Author axew3

    (@axewww)

    Ok, i’ve just take a look and for what i have understand, allowed chars in WordPress for usernames are these:

    a-z
    0-9
    _
    .
    @
    and space

    all the rest isn’t allowed in WordPress usernames.
    At best i’ve get out at moment and about this, the file
    class.wp.w3all-phpbb.php
    has been patched to correctly detect any unwanted chars in phpBB usernames, for users that need to be added in WordPress. The user will be correctly informed that can’t be added and no error will be thrown. A query as been fixed because was containing a problem. So thank to this report also this important aspect has been definitively resolved.

    Allowed usernames in WordPress are these for what i’ve understand. Now addition of phpBB user in WP is correctly handled in the correct way, improving the detection of any wrong phpBB username and eventually returning the correct message to user.
    The patch fix also a query that was wrongly write up.

    To patch, download file class.wp.w3all-phpbb.php and replace into
    /wp-content/plugins/wp-w3all-phpbb-integration

    Thread Starter andreyguild

    (@andreyguild)

    Thnx for all your good work.
    Some WP plugins, like Allow Cyrillic Usernames enable additional chars to be used in username.
    What they do is add filter on the sanitize_user hook and add more chars.

    As far as I can see, in the fix you enforce those chars, so even less ppl can SSO now:)
    That’s for the default WP install, but not WP with plugins, or am I wrong?

    Btw, you sanitize_user with strict = false and WP does it with strict = true AFAIK.

    I think even changing username to something like user13223 is better not logging them in.

    Plugin Author axew3

    (@axewww)

    check that the file class.wp.w3all-phpbb.php has been after re-patched because was lacking A-Z on pattern.
    Allowed chars in WordPress for usernames are (or should be) these:

    a-z
    A-Z
    0-9
    _
    .
    @
    and space

    “At this time i’ve not find out any other possible solution to this problem. An user could also be added in WordPress without filtering the username, but as on my fly test and an username archived as
    [b]a-z0-9_.\-@[/b]
    is parsed in WordPress output as
    [b]a-z0-9_.-@[/b]
    so i see very hard to allow the use of any char for WordPress usernames. Also should maybe be considered, before to be applied, the security aspect that this can maybe imply. Any hint or correction on this would be really appreciated!”

    https://www.axew3.com/w3/forums/viewtopic.php?f=2&t=683#p2707
    Yes i’ve see the usernames can be filtered: i have try to force the addition of users without any filter and also safely, but after, consider that an username
    archived on database as
    a-z0-9_.\-@
    is parsed in WordPress output as
    a-z0-9_.-@
    and effectively treated as it. It seem to me very hard so that will be possible to add these kind of chars in WP usernames. But as said maybe i’m wrong-

    • This reply was modified 7 years, 12 months ago by axew3.
    Plugin Author axew3

    (@axewww)

    p.s as i can (presumably within tomorrow) i will try as last chance to use wp filters
    pre_user_login and pre_user_nicename
    to see what happen and if wp will archive these values to be after suitable to use.

    Thread Starter andreyguild

    (@andreyguild)

    Atm I think that the problem is in nicename
    I’ve disable

    I’m not sure where its been set

    Plugin Author axew3

    (@axewww)

    the problem is that you can also force to work wp with wp_w3all to login the user with not allowed chars as username, but after, seem to me that wordpress not recognize by the way the cookie, and not setup for him a valid session.
    The plugin re-login the user each time in front end, and seem to work fine, but it isn’t, re-login each time the user, while loop in profile.php.
    In change, wordpress refuse you to login via his wp-login form with unwanted chars: more … even if you have an apparent valid cookie in WP released under wp_w3all and you disable the plugin to test an user with a valid cookie and this kind of unwanted username, you’ll see that wordpress ignore the cookie, and the user is logged out.
    Due to all the above at moment, and until no possible light about, the applied one is the “at max” solution.

    Thread Starter andreyguild

    (@andreyguild)

    Can you please show how nicename is set in the process of user creation by w3all
    I just want to set is as username without alterations and it would be nice to use it a display name too

    Plugin Author axew3

    (@axewww)

    ok andrey in the wild and with all that this imply … i’ve just go little more deep, and i’ve get the joke work.
    Now, this may imply some security problem, so better in case do something like what i will explain after (and still not totally clear also to me). Just let before point you to:
    how to add usernames in wordpress with wp_w3all, also with unwanted chars?
    open wp_w3all.php
    on bottom, just before the closing php tag
    ?>
    add the follow:

    function my_sanitize_user($user, $raw_user, $strict) {
    
        return $raw_user;
    }
    add_filter('sanitize_user', 'my_sanitize_user', 10, 3);

    now open class.wp.w3all-phpbb.php
    search for this code:

            if ( preg_match('/[^-0-9A-Za-z _.@]/',$phpbb_user_session[0]->username) ){
    	          echo '<p style="padding:30px;background-color:#fff;color:#000;font-size:1.3em">Sorry, your <strong>registered username on our forum contain characters not allowed on this CMS system</strong>, you can\'t be added or login in this site side (and you\'ll see this message) until logged in on forums as <b>'.$phpbb_user_session[0]->username.'</b>. Please return back and contact the administrator reporting about this error issue. Thank you <input type="button" value="Go Back" onclick="history.back(-1)" /></p>';
               return;
             }

    remove or comment out.
    Now when an user from phpBB come as logged in phpBB and visit wordpress, is added with his full username, but if the user try to access profile, then the code will loop.
    I’ve see that the reason is that the wp logged in cookie, in this case for an username like
    a-z0-9_.\-@
    store the cookie value as
    a-z0-9_.\\-@
    to resolve on the wild i’ve so open wp-includes/pluggable.php and search for
    wp_validate_auth_cookie( function
    and on it where code
    $user = get_user_by('login', $username);
    i’ve ADD just BEFORE this to test:
    $username = stripslashes($username);
    Now all work fine. You’ll see the user is logged and can now access to profile also, the cookie is recognized by wordpress.

    All this in this state is a security risk.
    1) the filter
    add_filter('sanitize_user', 'my_sanitize_user', 10, 3);
    not need to be used in this way, but now i know is possible to hook into.
    Then could be possible apply this rule/code: before to accept the username input, check that this same exact username exists in phpBB, then you can be sure it is an user coming from phpBB and existent. Would be necessary to disable registration and login on WordPress also. ALso would be possible to use the filter to sanitize in the right way and work around the problem.

    SO:

    I’m now quite sure that yes can be achieved, of course, without going to edit the function wp_validate_auth_cookie( that is not necessary (this is just a test!) and a wild dangerous thing. It can be maybe safe in this way only if you let register/login users exclusively in phpBB side.
    There are several hooks/filters that can be used, so i need to check how …
    What this about security, in total, imply, still isn’t clear but i will ask to smart slack boys at this point …

    • This reply was modified 7 years, 12 months ago by axew3.
    • This reply was modified 7 years, 12 months ago by axew3.
    • This reply was modified 7 years, 12 months ago by axew3.
    Plugin Author axew3

    (@axewww)

    Plugin Author axew3

    (@axewww)

    before to finish another plugin example this morning, i can assume that this is the solution to your problem whenever it is needed:
    usernames in wordpress with any character: the obscure way …
    cheers!

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

The topic ‘Special Chars in Usernames’ is closed to new replies.