diff options
-rw-r--r-- | modules/protocol/charybdis.cpp | 1 | ||||
-rw-r--r-- | modules/protocol/hybrid.cpp | 23 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 21 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 1 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 1 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 21 | ||||
-rw-r--r-- | src/protocol.cpp | 9 |
7 files changed, 73 insertions, 4 deletions
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 74e450d31..1d19f24bd 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -58,6 +58,7 @@ class CharybdisProto : public IRCDProto void SendServer(const Server *server) anope_override { ratbox->SendServer(server); } void SendChannel(Channel *c) anope_override { ratbox->SendChannel(c); } void SendTopic(const MessageSource &source, Channel *c) anope_override { ratbox->SendTopic(source, c); } + bool IsIdentValid(const Anope::string &ident) anope_override { return ratbox->IsIdentValid(ident); } void SendSQLine(User *, const XLine *x) anope_override { diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index a07cb62fb..f4254edf4 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -259,6 +259,29 @@ class HybridProto : public IRCDProto XLine x(nick); this->SendSQLineDel(&x); } + + bool IsIdentValid(const Anope::string &ident) anope_override + { + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; + + Anope::string chars = "~}|{ `_^]\\[ .-$"; + + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; + + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) + continue; + + if (chars.find(c) != Anope::string::npos) + continue; + + return false; + } + + return true; + } }; struct IRCDMessageBMask : IRCDMessage diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 2c9103702..0098ae90b 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -390,6 +390,27 @@ class InspIRCd12Proto : public IRCDProto { return mask.length() >= 3 && mask[1] == ':'; } + + bool IsIdentValid(const Anope::string &ident) anope_override + { + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; + + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; + + if (c >= 'A' && c <= '}') + continue; + + if ((c >= '0' && c <= '9') || c == '-' || c == '.') + continue; + + return false; + } + + return true; + } }; class InspIRCdExtBan : public ChannelModeList diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 34e87935a..a170b6a5d 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -72,6 +72,7 @@ class InspIRCd20Proto : public IRCDProto void SendLogout(User *u) anope_override { insp12->SendLogout(u); } void SendChannel(Channel *c) anope_override { insp12->SendChannel(c); } bool IsExtbanValid(const Anope::string &mask) anope_override { return insp12->IsExtbanValid(mask); } + bool IsIdentValid(const Anope::string &ident) anope_override { return insp12->IsIdentValid(ident); } }; class InspIRCdExtBan : public ChannelModeList diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index b7716bce1..dc6cef168 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -42,6 +42,7 @@ class RatboxProto : public IRCDProto void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(source, u, buf); } void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); } void SendTopic(const MessageSource &source, Channel *c) anope_override { hybrid->SendTopic(source, c); } + bool IsIdentValid(const Anope::string &ident) anope_override { return hybrid->IsIdentValid(ident); } void SendConnect() anope_override { diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 2da4af3e8..8e86ad729 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -376,6 +376,27 @@ class UnrealIRCdProto : public IRCDProto bi->Join(c); } } + + bool IsIdentValid(const Anope::string &ident) anope_override + { + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; + + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; + + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') + continue; + + if (c == '-' || c == '.' || c == '_') + continue; + + return false; + } + + return true; + } }; class UnrealExtBan : public ChannelModeList diff --git a/src/protocol.cpp b/src/protocol.cpp index 9ece3b529..ba44ea708 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -326,16 +326,17 @@ bool IRCDProto::IsChannelValid(const Anope::string &chan) bool IRCDProto::IsIdentValid(const Anope::string &ident) { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("chanlen")) + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) return false; for (unsigned i = 0; i < ident.length(); ++i) { const char &c = ident[i]; + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') - ; - else - return false; + continue; + + return false; } return true; |