diff --git a/src/wp-login.php b/src/wp-login.php index 45c207d81a..781f8b246f 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -904,7 +904,17 @@ switch ( $action ) { $errors = new WP_Error(); - if ( isset( $_POST['pass1'] ) && $_POST['pass1'] !== $_POST['pass2'] ) { + // Check if password is one or all empty spaces. + if ( ! empty( $_POST['pass1'] ) ) { + $_POST['pass1'] = trim( $_POST['pass1'] ); + + if ( empty( $_POST['pass1'] ) ) { + $errors->add( 'password_reset_empty_space', __( 'The password cannot be a space or all spaces.' ) ); + } + } + + // Check if password fields do not match. + if ( ! empty( $_POST['pass1'] ) && $_POST['pass1'] !== trim( $_POST['pass2'] ) ) { $errors->add( 'password_reset_mismatch', __( 'Error: The passwords do not match.' ) ); }