Skip to:
Content

BuddyPress.org

Opened 10 years ago

Last modified 10 years ago

#6389 new defect (bug)

buddypress doesn’t support chinese login name

Reported by: wenlujon's profile wenlujon Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: major Version: 2.2.1
Component: Route Parser Keywords: needs-patch needs-unit-tests
Cc: stephen@…

Description

I come from china and i’m setting up a forum for Chinese, currently, a Chinese username is allowed to register by adding a filter to sanitize_user(), and I can login in with the username, however, I can’t see my profile page in buddypress, for example, the profile page:
[my-site]/members/[my-chinese-username]/profile/edit/
is redirected to:
[my-site]/membersprofile/edit/
and it reports page not found.

another problem is that no link is generated if using AT[Chinese-username]

Change History (10)

#1 follow-up: @DJPaul
10 years ago

  • Component changed from Component - XProfile to API - Rewrite Rules
  • Keywords reporter-feedback added
  • Milestone changed from Awaiting Review to Under Consideration
  • Priority changed from high to normal

Hi wenlujon

Can you give us a sample Chinese username that we can use to test the problem? Thanks.

#2 in reply to: ↑ 1 @wenlujon
10 years ago

Replying to DJPaul:

Hi wenlujon

Can you give us a sample Chinese username that we can use to test the problem? Thanks.

sure, for example, 测试, which means test.

#3 @wenlujon
10 years ago

BTW, if you have any ideas or fixes, just let me know, i can test the fixes in no time.:)

#4 @wenlujon
10 years ago

I added the following code for supporting Chinese name register, in ms-functions.php:
--- wp-includes/ms-functions.php.orig 2015-04-21 13:32:39.181687801 +0000
+++ wp-includes/ms-functions.php 2015-04-21 14:21:02.772291702 +0000
@@ -462,7 +462,7 @@

$orig_username = $user_name;
$user_name = preg_replace( '/\s+/', , sanitize_user( $user_name, true ) );

if ( $user_name != $orig_username + if ( $user_name != $orig_username
preg_match( '/[a-z0-9]/', $user_name ) ) {
(preg_match( '/[a-zA-Z0-9]/', $user_name ) && preg_match( '/[\u4e00-\u9fa5]/', $user_name ) )) {

$errors->add( 'user_name', ( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
$user_name = $orig_username;

}

and add the filter in my theme functions.php:
function ludou_non_strict_login( $username, $raw_username, $strict ) {

if( !$strict )

return $username;

return sanitize_user(stripslashes($raw_username), false);

}
add_filter('sanitize_user', 'ludou_non_strict_login', 10, 3);

#5 follow-up: @boonebgorges
10 years ago

Thanks for your help with this so far, wenlujon.

It's worth noting that, if you're using WordPress Multisite (as you appear to be, given your changes in ms-functions.php), the restrictions on login characters come from WordPress and not from BuddyPress. See https://core.trac.wordpress.org/ticket/17904. BP uses WP's user system, and it's unlikely that we would make username requirements less strict that WP does in the case of multisite.

That being said, it's likely that in the case of non-MS, we are being overzealous about sanitization of user_login and especially user_nicename in various places. Our testing should be focused on non-MS.

#6 in reply to: ↑ 5 @wenlujon
10 years ago

  • Keywords reporter-feedback removed

Replying to boonebgorges:

Thanks for your help with this so far, wenlujon.

It's worth noting that, if you're using WordPress Multisite (as you appear to be, given your changes in ms-functions.php), the restrictions on login characters come from WordPress and not from BuddyPress. See https://core.trac.wordpress.org/ticket/17904. BP uses WP's user system, and it's unlikely that we would make username requirements less strict that WP does in the case of multisite.

That being said, it's likely that in the case of non-MS, we are being overzealous about sanitization of user_login and especially user_nicename in various places. Our testing should be focused on non-MS.

yes, i'm using MS. and i feel comfortable to tweak the sanitize_username so that Chinese username can be supported (majority of users here like to login in through Chinese name).

I can login in with the chinese username and even post in the forum.

however, i encounter 2 problems afterwards:

  1. can't access the user profile through buddypress anymore (the link is redirected as illustrated in the description.
  2. can't mention the user through AT[chinese login name] since no link is created.

are you saying it won't be a problem if i use single site? anyway, i also need MP (one for the blog and another for the forum, i need to manage them separately but share users).

#7 @boonebgorges
10 years ago

  • Keywords needs-patch needs-unit-tests added; chinese login name removed
  • Milestone changed from Under Consideration to Future Release

are you saying it won't be a problem if i use single site? anyway, i also need MP (one for the blog and another for the forum, i need to manage them separately but share users).

I'm saying that your modifications to ms-functions.php and sanitize_user() will not be supported natively in BuddyPress when running on Multisite. So when BP's developers are debugging, they should be sure to test in non-MS. If you want to modify your own site so that multisite supports user logins like this, that's your prerogative, but we don't officially support it :)

#8 @wenlujon
10 years ago

I'm fine if you test it in non-MS. looking forward to the root cause.

Last edited 10 years ago by wenlujon (previous) (diff)

#9 @wenlujon
10 years ago

another symptom i found:
i tried to register with the username 四天 (which means four days), and i can see the profile page now. however, the mention becomes:
@-2

and i checked the database, found that the user_nicename in wp_users for the user is -2.

and i can even mention the user through @-2

why is that?

#10 @netweb
10 years ago

  • Cc stephen@… added
Note: See TracTickets for help on using tickets.