Make WordPress Core

Opened 2 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#65440 closed defect (bug) (duplicate)

WordPress 7.0 allows spaces in usernames

Reported by: santiko86's profile santiko86 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: Cc:

Description

Issue: WordPress 7.0 accepts usernames with spaces, which should be rejected.

Steps to reproduce:

  1. Go to UsersAdd New
  2. Enter username with spaces: k a l i
  3. Save the user
  4. WordPress accepts it

Expected behavior:
Username should be rejected or automatically trimmed of spaces

Actual behavior:
Multiple users created with spaces: k a l i, K A L I, ka l i

Environment:

  • WordPress 7.0
  • Default theme (no plugins)
  • No custom code

Issue: Usernames with spaces break author URLs and create duplicates

POC: https://drive.google.com/drive/folders/1PecXgSMHaagMhxjM_dK78_TlH2vWkYBP?usp=sharing

Proposed Fixed

  1. Reject username with space

In /wp-includes/user.php or /wp-admin/user-new.php, add validation:

// Validate username - no spaces allowed
if ( preg_match( '/\s/', $username ) ) {
    wp_die( __( 'Usernames cannot contain spaces.' ) );
}

or

  1. Trimmed all spaces
// Remove spaces from username before saving
$username = trim( str_replace( ' ', '', $username ) );

Attachments (1)

bandicam 2026-06-09 13-49-50-349.mp4 (7.8 MB) - added by santiko86 2 weeks ago.
This is POC video.

Change History (3)

@santiko86
2 weeks ago

This is POC video.

#1 @Presskopp
2 weeks ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #44690.

There has been some discussion:

See #49395, #59084

#2 @jorbin
2 weeks ago

  • Focuses ui javascript administration sustainability coding-standards removed
  • Milestone Awaiting Review deleted
  • Version 7.0 deleted
Note: See TracTickets for help on using tickets.