Opened 14 years ago
Closed 14 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 14 years ago by toemon
comment:2 Changed 14 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 14 years ago by toemon
- Resolution 修正済み deleted
- Status changed from closed to reopened
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 14 years ago by toemon
- Resolution set to fixed
- Status changed from reopened to closed
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 ); }