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

[stable10] username must be at least 3 characters long #29237

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/private/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public function searchDisplayName($pattern, $limit = null, $offset = null) {
*/
public function createUser($uid, $password) {
$l = \OC::$server->getL10N('lib');

// Check the name for bad characters
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-'"
if (preg_match('/[^a-zA-Z0-9 _\.@\-\']/', $uid)) {
Expand All @@ -303,6 +304,12 @@ public function createUser($uid, $password) {
if (strlen(trim($uid, "\t\n\r\0\x0B\xe2\x80\x8b")) !== strlen(trim($uid))) {
throw new \Exception($l->t('Username contains whitespace at the beginning or at the end'));
}

// Username must be at least 3 characters long
if(strlen($uid) < 3) {
throw new \Exception($l->t('The username must be at least 3 characters long'));
}

// No empty password
if (trim($password) == '') {
throw new \Exception($l->t('A valid password must be provided'));
Expand Down