Ticket #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
comment:2 Changed 7 months ago by toemon
- Status changed from new to closed
- Resolution set to 修正済み
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 7 months ago by toemon
- Status changed from closed to reopened
- Resolution 修正済み deleted
r794 の修正では、たとえばユーザ名が「藤右衛門123」だと、「123」として登録されてしまう。
XOOPSユーザから、WordPress?ユーザデータを作成する際は、sanitize_userそのものをパスするようにしたほうがよいかも、
function sanitize_user_multibyte($username, $raw_username, $strict){
if ($username !== $raw_username)
return $raw_username;
return $username;
}
comment:4 Changed 7 months ago by toemon
- Status changed from reopened to closed
- Resolution set to fixed
(In [797]) XOOPSユーザから、WordPress?ユーザデータを作成する時
WordPress?からユーザデータをアップデートする時
は、実質的にsanitize_userをパスする。
WordPress?側から新規ユーザー登録する場合はsanitize_userを有効にする。
fixed #408
Note: See
TracTickets for help on using
tickets.
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 ); }