Make WordPress Core


Ignore:
Timestamp:
10/06/2015 05:34:47 AM (10 years ago)
Author:
DrewAPicture
Message:

Users: Empty sanitized usernames should be considered invalid when passed through validate_username().

Adds tests.

Props gwinhlopez for the initial patch.
Props mordauk, chriscct7.
Fixes #24618.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user-functions.php

    r34820 r34856  
    11771177 *
    11781178 * @since 2.0.1
     1179 * @since 4.4.0 Empty sanitized usernames are now considered invalid
    11791180 *
    11801181 * @param string $username Username.
     
    11831184function validate_username( $username ) {
    11841185    $sanitized = sanitize_user( $username, true );
    1185     $valid = ( $sanitized == $username );
     1186    $valid = ( $sanitized == $username && ! empty( $sanitized ) );
     1187
    11861188    /**
    11871189     * Filter whether the provided username is valid or not.
Note: See TracChangeset for help on using the changeset viewer.