Make WordPress Core

Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#65440 closed defect (bug) (duplicate)

WordPress 7.0 allows spaces in usernames

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

Description

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

Steps to reproduce:

  1. Go to Users → Add 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 4 months ago.
This is POC video.

Change History (3)

@santiko86
4 months ago

This is POC video.

#1 @Presskopp
4 months ago

  • Resolution → duplicate
  • Status new → closed

Duplicate of #44690.

There has been some discussion:

See #49395, #59084

#2 @jorbin
4 months ago

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