#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:
- Go to Users → Add New
- Enter username with spaces:
k a l i - Save the user
- 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
- 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
- Trimmed all spaces
// Remove spaces from username before saving $username = trim( str_replace( ' ', '', $username ) );
Attachments (1)
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This is POC video.