* 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.
*/
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();
public static function isBlacklisted($str)
{
$blacklist = common_config('nickname', 'blacklist');
+ if(!$blacklist)
+ return false;
return in_array($str, $blacklist);
}