diff --git a/include/protocol.h b/include/protocol.h index 911c78d68..73373f881 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -92,9 +92,6 @@ public: /* See ns_cert */ bool CanCertFP = false; - /* Can we send arbitrary message tags? */ - bool CanSendTags = false; - /* Can users log out before being fully connected? */ bool CanSVSLogout = false; @@ -288,6 +285,7 @@ public: virtual bool IsIdentValid(const Anope::string &); virtual bool IsHostValid(const Anope::string &); virtual bool IsExtbanValid(const Anope::string &) { return false; } + virtual bool IsTagValid(const Anope::string &, const Anope::string &) { return false; } /** Retrieve the maximum number of list modes settable on this channel * Defaults to Config->ListSize diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp index 7cb86598a..17f6fb14a 100644 --- a/modules/protocol/inspircd.cpp +++ b/modules/protocol/inspircd.cpp @@ -117,7 +117,6 @@ public: CanSVSHold = true; CanSVSLogout = true; CanCertFP = true; - CanSendTags = true; RequiresID = true; MaxModes = 20; MaxLine = 4096; @@ -583,6 +582,12 @@ public: return true; } + + bool IsTagValid(const Anope::string &name, const Anope::string &tvalue) + { + // InspIRCd accepts arbitrary message tags. + return true; + } }; class InspIRCdAutoOpMode final diff --git a/src/process.cpp b/src/process.cpp index a81340250..4ba0e23f0 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -126,17 +126,21 @@ bool IRCDProto::Parse(const Anope::string &buffer, Anope::map &ta bool IRCDProto::Format(Anope::string &message, const Anope::map &tags, const MessageSource &source, const Anope::string &command, const std::vector ¶ms) { std::stringstream buffer; - if (CanSendTags && !tags.empty()) + if (!tags.empty()) { char separator = '@'; for (const auto &[tname, tvalue] : tags) { - buffer << separator << tname; - if (!tvalue.empty()) - buffer << '=' << tvalue; - separator = ';'; + if (IRCD->IsTagValid(tname, tvalue)) + { + buffer << separator << tname; + if (!tvalue.empty()) + buffer << '=' << tvalue; + separator = ';'; + } } - buffer << ' '; + if (separator != '@') + buffer << ' '; } if (source.GetServer())