Merge pull request #36067 from nextcloud/enh/noid/spaces-are-allowed-in-userids

spaces are allowed in userids
This commit is contained in:
blizzz 2023-01-13 10:45:27 +01:00 committed by GitHub
commit 2db1e75be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -714,10 +714,10 @@ class Manager extends PublicEmitter implements IUserManager {
$l = Server::get(IFactory::class)->get('lib');
// Check the name for bad characters
// Allowed are: "a-z", "A-Z", "0-9" and "_.@-'"
// Allowed are: "a-z", "A-Z", "0-9", spaces and "_.@-'"
if (preg_match('/[^a-zA-Z0-9 _.@\-\']/', $uid)) {
throw new \InvalidArgumentException($l->t('Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'));
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'));
}
// No empty username

View file

@ -309,23 +309,23 @@ class ManagerTest extends TestCase {
public function dataCreateUserInvalid() {
return [
['te?st', 'foo', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\tst", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\nst", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\rst", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\0st", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\x0Bst", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\xe2st", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\x80st", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
["te\x8bst", '', 'Only the following characters are allowed in a username:'
. ' "a-z", "A-Z", "0-9", and "_.@-\'"'],
. ' "a-z", "A-Z", "0-9", spaces and "_.@-\'"'],
['', 'foo', 'A valid username must be provided'],
[' ', 'foo', 'A valid username must be provided'],
[' test', 'foo', 'Username contains whitespace at the beginning or at the end'],