diff options
| author | Sadie Powell <sadie@witchery.services> | 2022-01-12 22:05:59 +0000 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2022-01-12 22:08:35 +0000 |
| commit | a631028660d527f509c3b028cfa5f2903a125077 (patch) | |
| tree | 830ba6644bb312af32847db654bfb842ed44a7cd /modules/protocol/hybrid.cpp | |
| parent | 4e5fc9797c2ea285e855f808dc65694d1cdba358 (diff) | |
| parent | 04257b9d6ab0fa1a63ade1d2ad0edc2d08eb74ce (diff) | |
Merge branch '2.0' into 2.1.
Diffstat (limited to 'modules/protocol/hybrid.cpp')
| -rw-r--r-- | modules/protocol/hybrid.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 8d9267438..7c3d98a63 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -1,6 +1,6 @@ /* ircd-hybrid protocol module. Minimum supported version of ircd-hybrid is 8.2.23. * - * (C) 2003-2021 Anope Team <team@anope.org> + * (C) 2003-2022 Anope Team <team@anope.org> * (C) 2012-2020 ircd-hybrid development team * * Please read COPYING and README for further details. @@ -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; |
