Page MenuHomePhorge

D25841.1734097436.diff
No OneTemporary

D25841.1734097436.diff

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,16 @@
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.',
+ new PhutilNumber(self::MAXIMUM_REALNAME_LENGTH));
+ }
+
+ public static function validateRealName($realname) {
+ return strlen($realname) <= self::MAXIMUM_REALNAME_LENGTH;
+ }
+
public static function getDefaultProfileImageURI() {
return celerity_get_resource_uri('/rsrc/image/avatar.png');
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 13, 13:43 (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1008189
Default Alt Text
D25841.1734097436.diff (1 KB)

Event Timeline