X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fnickname.php;h=e21517497a18cd0587530bc14519fb9ebf310ff5;hb=3290227b50582ed29790f0bb10210362ca2f4093;hp=5a5b515b4dfceec44f70c3f4b63c7e7b7285ef98;hpb=29662eef5e479f8ebcbff1ce3c89e15beb43f7c6;p=quix0rs-gnu-social.git diff --git a/lib/nickname.php b/lib/nickname.php index 5a5b515b4d..e21517497a 100644 --- a/lib/nickname.php +++ b/lib/nickname.php @@ -54,7 +54,10 @@ class Nickname * We could probably use an email regex here, but mainly we are interested * in matching it in our URLs, like https://social.example/user@example.com */ - const WEBFINGER_FMT = '[0-9a-zA-Z_]{1,64}\@[0-9a-zA-Z_-.]{3,255}'; + const WEBFINGER_FMT = '(?:\w+[\w\-\_\.]*)?\w+\@'.URL_REGEX_DOMAIN_NAME; + + // old one without support for -_. in nickname part: + // const WEBFINGER_FMT = '[0-9a-zA-Z_]{1,64}\@[0-9a-zA-Z_-.]{3,255}'; /** * Regex fragment for checking a canonical nickname. @@ -126,15 +129,17 @@ class Nickname */ public static function normalize($str, $checkuse=false) { + if (mb_strlen($str) > self::MAX_LEN) { + // Display forms must also fit! + throw new NicknameTooLongException(); + } + // We should also have UTF-8 normalization (Ã¥ to a etc.) $str = trim($str); $str = str_replace('_', '', $str); $str = mb_strtolower($str); - if (mb_strlen($str) > self::MAX_LEN) { - // Display forms must also fit! - throw new NicknameTooLongException(); - } elseif (mb_strlen($str) < 1) { + if (mb_strlen($str) < 1) { throw new NicknameEmptyException(); } elseif (!self::isCanonical($str)) { throw new NicknameInvalidException(); @@ -172,6 +177,8 @@ class Nickname public static function isBlacklisted($str) { $blacklist = common_config('nickname', 'blacklist'); + if(!$blacklist) + return false; return in_array($str, $blacklist); }