XPressME Integration Kit

Trac

Opened 12 years ago

Closed 12 years ago

#408 closed バグ(bug) (fixed)

ログイン名がマルチバイトだとユーザ登録できない

Reported by: toemon Owned by: toemon
Priority: 普通 Milestone: Ver.2.4.2
Component: 一般 Version: 2.4.1
Severity: 普通 Keywords:
Cc:

Description

XOOPSの管理者名が日本語などマルチバイトだと、XPressのインストールの際、インストールは終了するけれどXPress側のユーザーテーブルにデータが挿入されず、インストール後に管理者がログインできない。
thx naao

Change History (4)

comment:1 Changed 12 years ago by toemon

WP側のユーザ登録時wp-include/formatting.phpのsanitize_user()でsanitize_user( 'ユーザー名', true )としてサニタイズされるため、マルチバイト名が使えなくなってしまっている。

function sanitize_user( $username, $strict = false ) {
	$raw_username = $username;
	$username = wp_strip_all_tags( $username );
	$username = remove_accents( $username );
	// Kill octets
	$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
	$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities

	// If strict, reduce to ASCII for max portability.
	if ( $strict )
		$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );

	$username = trim( $username );
	// Consolidate contiguous whitespace
	$username = preg_replace( '|\s+|', ' ', $username );

	return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
}

comment:2 Changed 12 years ago by toemon

  • Resolution set to 修正済み
  • Status changed from new to closed

r794 にて修正完了

add_filter('sanitize_user', "sanitize_user_multibyte" ,10,3);

にて

function sanitize_user_multibyte($username, $raw_username, $strict){
	if ($username == "" && $strict){
		if ($raw_username == ""){
			return $username;
		} else{
			return sanitize_user($raw_username, false);
		}
	} else {
		return $username;
	}
}

を呼び出してフィルタリングする。

comment:3 Changed 12 years ago by toemon

  • Resolution 修正済み deleted
  • Status changed from closed to reopened

r792 の修正では、たとえばユーザ名が[藤右衛門123]だと、[123]として登録されてしまう。

XOOPSユーザから、WordPressユーザデータを作成する際は、sanitize_userそのものをパスするようにしたほうがよいかも、

function sanitize_user_multibyte($username, $raw_username, $strict){
	if ($username !== $raw_username)
		return $raw_username;
	return $username;
}
Version 0, edited 12 years ago by toemon (next)

comment:4 Changed 12 years ago by toemon

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [797]) XOOPSユーザから、WordPressユーザデータを作成する時
WordPressからユーザデータをアップデートする時
は、実質的にsanitize_userをパスする。
WordPress側から新規ユーザー登録する場合はsanitize_userを有効にする。
fixed #408

Note: See TracTickets for help on using tickets.