diff --git a/src/applications/auth/controller/PhabricatorAuthRegisterController.php b/src/applications/auth/controller/PhabricatorAuthRegisterController.php --- a/src/applications/auth/controller/PhabricatorAuthRegisterController.php +++ b/src/applications/auth/controller/PhabricatorAuthRegisterController.php @@ -342,6 +342,10 @@ if (!strlen($value_realname) && $require_real_name) { $e_realname = pht('Required'); $errors[] = pht('Real name is required.'); + } else if ($value_realname && + !PhabricatorUser::validateRealName($value_realname)) { + $e_realname = pht('Invalid'); + $errors[] = PhabricatorUser::describeValidRealName(); } else { $e_realname = null; } diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -26,6 +26,7 @@ const SESSION_TABLE = 'phabricator_session'; const NAMETOKEN_TABLE = 'user_nametoken'; const MAXIMUM_USERNAME_LENGTH = 64; + const MAXIMUM_REALNAME_LENGTH = 256; protected $userName; protected $realName; @@ -550,6 +551,19 @@ return (bool)preg_match('/^[a-zA-Z0-9._-]*[a-zA-Z0-9_-]\z/', $username); } + public static function describeValidRealName() { + return pht( + 'Real Name must have no more than %d characters.', + self::MAXIMUM_REALNAME_LENGTH); + } + + public static function validateRealName($realname) { + if (strlen($realname) > self::MAXIMUM_REALNAME_LENGTH) { + return false; + } + return true; + } + public static function getDefaultProfileImageURI() { return celerity_get_resource_uri('/rsrc/image/avatar.png'); }