Make WordPress Core

Ticket #59485: 59485.2.patch

File 59485.2.patch, 655 bytes (added by ankitkumarshah, 7 months ago)

I've attached a patch that uses sanitize_user() for username validation.

  • src/wp-includes/user.php

    diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
    index f60dbe5d3f..5723031637 100644
    a b function wp_insert_user( $userdata ) { 
    21702170        $user_login = trim( $pre_user_login );
    21712171
    21722172        // user_login must be between 0 and 60 characters.
    2173         if ( empty( $user_login ) ) {
     2173        if ( empty( sanitize_user( $user_login ) ) ) {
    21742174                return new WP_Error( 'empty_user_login', __( 'Cannot create a user with an empty login name.' ) );
    21752175        } elseif ( mb_strlen( $user_login ) > 60 ) {
    21762176                return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) );