Ticket #13162: 13162.diff
File 13162.diff, 4.3 KB (added by , 14 years ago) |
---|
-
wp-login.php
271 271 function register_new_user($user_login, $user_email) { 272 272 $errors = new WP_Error(); 273 273 274 $ user_login = sanitize_user( $user_login );274 $sanitized_user_login = sanitize_user( $user_login ); 275 275 $user_email = apply_filters( 'user_registration_email', $user_email ); 276 276 277 277 // Check the username 278 if ( $ user_login == '' )278 if ( $sanitized_user_login == '' ) 279 279 $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.')); 280 280 elseif ( !validate_username( $user_login ) ) { 281 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid .Please enter a valid username.'));282 $ user_login = '';283 } elseif ( username_exists( $ user_login ) )281 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid because it uses characters illegal characters. Please enter a valid username.')); 282 $sanitized_user_login = ''; 283 } elseif ( username_exists( $sanitized_user_login ) ) 284 284 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); 285 285 286 286 // Check the e-mail address … … 292 292 } elseif ( email_exists( $user_email ) ) 293 293 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); 294 294 295 do_action('register_post', $ user_login, $user_email, $errors);295 do_action('register_post', $sanitized_user_login, $user_email, $errors); 296 296 297 $errors = apply_filters( 'registration_errors', $errors, $ user_login, $user_email );297 $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 298 298 299 299 if ( $errors->get_error_code() ) 300 300 return $errors; 301 301 302 302 $user_pass = wp_generate_password(); 303 $user_id = wp_create_user( $ user_login, $user_pass, $user_email );303 $user_id = wp_create_user( $saitized_user_login, $user_pass, $user_email ); 304 304 if ( !$user_id ) { 305 305 $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email'))); 306 306 return $errors; -
wp-includes/formatting.php
735 735 */ 736 736 function sanitize_user( $username, $strict = false ) { 737 737 $raw_username = $username; 738 $username = wp_strip_all_tags($username); 738 $username = wp_strip_all_tags( $username ); 739 $username = remove_accents( $username ); 739 740 // Kill octets 740 $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username);741 $username = preg_replace( '/&.+?;/', '', $username); // Kill entities741 $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); 742 $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities 742 743 743 744 // If strict, reduce to ASCII for max portability. 744 745 if ( $strict ) 745 $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username);746 $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); 746 747 747 748 // Consolidate contiguous whitespace 748 $username = preg_replace( '|\s+|', ' ', $username);749 $username = preg_replace( '|\s+|', ' ', $username ); 749 750 750 return apply_filters( 'sanitize_user', $username, $raw_username, $strict);751 return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); 751 752 } 752 753 753 754 /** -
wp-admin/includes/user.php
158 158 if ( !empty( $pass1 ) ) 159 159 $user->user_pass = $pass1; 160 160 161 if ( !$update && !validate_username( $user->user_login) )162 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid . Please enter a valid username.' ));161 if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) 162 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses characters illegal characters. Please enter a valid username.' )); 163 163 164 164 if ( !$update && username_exists( $user->user_login ) ) 165 165 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ));