No Code Attached Yet bug
avatar aboarken
aboarken
26 Sep 2026

What happened?

When creating a new user, Joomla allows spaces to be entered and saved as part of the username.

There is no validation message, and the whitespace remains part of the username.

Version

6.1

Expected result

The username should not accept spaces.

For example:

"Ahmad Moussa" → should be rejected
" AhmadMoussa" → should either be trimmed or rejected
"AhmadMoussa" → should be accepted

I think the username field should have proper validation to prevent whitespace from being used or stored.

Actual result

For example, usernames such as "Ahmad Moussa", "AhmadMoussa " (with a trailing space), or " AhmadMoussa" (with a leading space) can be saved successfully. Joomla accepts and saves usernames containing spaces, including leading and trailing spaces.

System Information

Joomla 6.1.3
PHP: 8.4.23

Additional Comments

Steps to reproduce

Go to Users → Manage in the Joomla Administrator.
Create a new user.
Enter a username such as "Ahmad Moussa"
Save the user.

The user is created successfully, and the username still contains the space.

Step to resolve

  1. Update the username validation

File:
libraries/src/Table/User.php

Find this:
preg_match('#[<>"'%;()&\\]|\.\./#', $this->username)

Change it to:
preg_match('#[\s<>"'%;()&\\]|\.\./#', $this->username)

So the complete condition becomes:

if (
preg_match('#[\s<>"'%;()&\\]|\.\./#', $this->username) || StringHelper::strlen($this->username) < 2
|| $filterInput->clean($this->username, 'TRIM') !== $this->username || StringHelper::strlen($this->username) > 150
) {
$this->setError(Text::sprintf('JLIB_DATABASE_ERROR_VALID_AZ09', 2));

return false;

}

I will create a pull request for this issue.

avatar aboarken aboarken - open - 26 Sep 2026
avatar joomla-cms-bot joomla-cms-bot - change - 26 Sep 2026
Labels Added: No Code Attached Yet bug
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Sep 2026
avatar aboarken aboarken - change - 26 Sep 2026
The description was changed
avatar aboarken aboarken - edited - 26 Sep 2026
avatar aboarken aboarken - change - 26 Sep 2026
The description was changed
avatar aboarken aboarken - edited - 26 Sep 2026
avatar santoshikumbhar3-art
santoshikumbhar3-art - comment - 12 Oct 2026

Hi, I'd like to contribute to this issue. I'll investigate how username validation is handled and try to reproduce the problem. Could you share any guidance on the expected validation behavior or relevant test?

Add a Comment

Login with GitHub to post a comment