From: Matthias Schmidt Date: Tue, 27 Feb 2018 16:39:46 +0000 (+0100) Subject: Add missing (explicit) username length validation in username form field X-Git-Tag: 5.2.0_Alpha_1~804 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=605bf171787a319b47793da04bcdb95807bc8b3b;p=GitHub%2FWoltLab%2FWCF.git Add missing (explicit) username length validation in username form field See #2509 --- diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UsernameFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UsernameFormField.class.php index d1ff62afac..475af9e0f2 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UsernameFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UsernameFormField.class.php @@ -64,11 +64,18 @@ class UsernameFormField extends AbstractFormField implements IMaximumLengthFormF $this->addValidationError(new FormFieldValidationError('empty')); } } - else if (!UserUtil::isValidUsername($this->getValue())) { - $this->addValidationError(new FormFieldValidationError('invalid', 'wcf.form.field.username.error.invalid')); - } - else if (!UserUtil::isAvailableUsername($this->getValue())) { - $this->addValidationError(new FormFieldValidationError('notUnique', 'wcf.form.field.username.error.notUnique')); + else { + $this->validateMinimumLength($this->getValue()); + $this->validateMaximumLength($this->getValue()); + + if (empty($this->getValidationErrors())) { + if (!UserUtil::isValidUsername($this->getValue())) { + $this->addValidationError(new FormFieldValidationError('invalid', 'wcf.form.field.username.error.invalid')); + } + else if (!UserUtil::isAvailableUsername($this->getValue())) { + $this->addValidationError(new FormFieldValidationError('notUnique', 'wcf.form.field.username.error.notUnique')); + } + } } parent::validate();