#65440 closed defect (bug) (duplicate)
WordPress 7.0 allows spaces in usernames
| Reported by: |
|
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:
- 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)
Note: See
TracTickets for help on using
tickets.
This is POC video.