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. Built from https://develop.svn.wordpress.org/trunk@34856 git-svn-id: http://core.svn.wordpress.org/trunk@34821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
99be7beda0
commit
7b82d75ec8
|
@ -1176,13 +1176,15 @@ function email_exists( $email ) {
|
||||||
* Checks whether a username is valid.
|
* Checks whether a username is valid.
|
||||||
*
|
*
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
|
* @since 4.4.0 Empty sanitized usernames are now considered invalid
|
||||||
*
|
*
|
||||||
* @param string $username Username.
|
* @param string $username Username.
|
||||||
* @return bool Whether username given is valid
|
* @return bool Whether username given is valid
|
||||||
*/
|
*/
|
||||||
function validate_username( $username ) {
|
function validate_username( $username ) {
|
||||||
$sanitized = sanitize_user( $username, true );
|
$sanitized = sanitize_user( $username, true );
|
||||||
$valid = ( $sanitized == $username );
|
$valid = ( $sanitized == $username && ! empty( $sanitized ) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter whether the provided username is valid or not.
|
* Filter whether the provided username is valid or not.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34855';
|
$wp_version = '4.4-alpha-34856';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue