Skip to content
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 @@ -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)) {
Expand All @@ -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'));
Expand Down