Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Numeric usernames can start with a space issue #4489

Merged
merged 2 commits into from
Oct 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions libraries/joomla/table/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,30 +171,32 @@ public function check()
$this->id = null;
}

$filterInput = JFilterInput::getInstance();

// Validate user information
if (trim($this->name) == '')
if ($filterInput->clean($this->name, 'TRIM') == '')
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_YOUR_NAME'));

return false;
}

if (trim($this->username) == '')
if ($filterInput->clean($this->username, 'TRIM') == '')
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_A_USER_NAME'));

return false;
}

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

return false;
}

if ((trim($this->email) == "") || !JMailHelper::isEmailAddress($this->email))
if (($filterInput->clean($this->email, 'TRIM') == "") || !JMailHelper::isEmailAddress($this->email))
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_VALID_MAIL'));

Expand Down