From a8e48a71c51e8be73d121ed5a9e98ed92caab41f Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 16 May 2013 14:47:31 +0000 Subject: - Merged valid_username() and clean_user_name() git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2068 82007160-df01-0410-b94d-b575c5fd34c7 --- src/s_user.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/s_user.c b/src/s_user.c index 5e22121..a6f82d5 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -390,7 +390,7 @@ register_local_user(struct Client *source_p) } /* valid user name check */ - if (valid_username(source_p->username) == 0) + if (valid_username(source_p->username, 1) == 0) { char tmpstr2[IRCD_BUFSIZE]; @@ -674,7 +674,7 @@ valid_hostname(const char *hostname) * style of username */ int -valid_username(const char *username) +valid_username(const char *username, const int local) { int dots = 0; const char *p = username; @@ -684,27 +684,37 @@ valid_username(const char *username) if (*p == '~') ++p; - /* reject usernames that don't start with an alphanum + /* + * Reject usernames that don't start with an alphanum * i.e. reject jokers who have '-@somehost' or '.@somehost' * or "-hi-@somehost", "h-----@somehost" would still be accepted. */ if (!IsAlNum(*p)) return 0; - while (*++p) + if (local) { - if ((*p == '.') && ConfigFileEntry.dots_in_ident) + while (*++p) { - if (++dots > ConfigFileEntry.dots_in_ident) - return 0; - if (!IsUserChar(*(p + 1))) + if ((*p == '.') && ConfigFileEntry.dots_in_ident) + { + if (++dots > ConfigFileEntry.dots_in_ident) + return 0; + if (!IsUserChar(*(p + 1))) + return 0; + } + else if (!IsUserChar(*p)) return 0; } - else if (!IsUserChar(*p)) - return 0; + } + else + { + while (*++p) + if (!IsUserChar(*p)) + return 0; } - return 1; + return p - username <= USERLEN;; } /* clean_nick_name() -- cgit