diff options
-rw-r--r-- | modules/protocol/hybrid.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 640408052..3a1b6ce59 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -280,16 +280,30 @@ class HybridProto : public IRCDProto if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) return false; - Anope::string chars = "~}|{ `_^]\\[ .-$"; + /* + * If the user name begins with a tilde (~), make sure there is at least + * one succeeding character. + */ + unsigned i = ident[0] == '~'; + if (i >= ident.length()) + return false; + + /* User names may not start with a '-', '_', or '.'. */ + const char &a = ident[i]; + if (a == '-' || a == '_' || a == '.') + return false; - for (unsigned i = 0; i < ident.length(); ++i) + for (i = 0; i < ident.length(); ++i) { const char &c = ident[i]; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) + /* A tilde can only be used as the first character of a user name. */ + if (c == '~' && i == 0) continue; - if (chars.find(c) != Anope::string::npos) + if ((c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.') continue; return false; |