]> source.dussan.org Git - nextcloud-server.git/commitdiff
move whitspace check to user manager
authorVincent Chan <plus.vincchan@gmail.com>
Wed, 3 Feb 2016 13:09:15 +0000 (14:09 +0100)
committerVincent Chan <plus.vincchan@gmail.com>
Wed, 3 Feb 2016 13:09:15 +0000 (14:09 +0100)
lib/private/user/manager.php
settings/js/users/users.js

index 86750dcd994d0c2180b978bdd0aff9cdd31f534a..6798a7340c32794a43fd19edce554ead06c5fb56 100644 (file)
@@ -265,6 +265,10 @@ class Manager extends PublicEmitter implements IUserManager {
                if (trim($uid) == '') {
                        throw new \Exception($l->t('A valid username must be provided'));
                }
+               // No whitespace at the beginning or at the end
+               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'));
+               }
                // No empty password
                if (trim($password) == '') {
                        throw new \Exception($l->t('A valid password must be provided'));
index 16faaf667ecbcc1849a8317e27538dcbf3fa9251..151ab6cdeccd1aae2b06e72748fe2401d8611200 100644 (file)
@@ -776,12 +776,6 @@ $(document).ready(function () {
                                t('settings', 'Error creating user'));
                        return false;
                }
-               if ($.trim(username).length !== username.length) {
-                       OC.dialogs.alert(
-                               t('settings', 'Username contains whitespace at the beginning or at the end'),
-                               t('settings', 'Error creating user'));
-                       return false;
-               }
                if ($.trim(password) === '') {
                        OC.dialogs.alert(
                                t('settings', 'A valid password must be provided'),