diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 822ece3aa94d..84f09111297f 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -274,6 +274,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)) { @@ -288,6 +289,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'));