diff options
author | Sadie Powell <sadie@witchery.services> | 2024-02-26 15:44:36 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-02-26 15:50:35 +0000 |
commit | 57674f5869a216e0ffc8a7c9cb59f86d1bae1f88 (patch) | |
tree | e83abffe6aa40a091fdd7e2cb1f170731e1c9d71 | |
parent | c6cb4ba159a8916243d7ac5a5c4e8d13942baf99 (diff) |
Replace IRCDProto::CanSendTags with IsTagValid.
Not every IRC server accepts arbitrary tags so this is a better
way to handle tag filtering.
-rw-r--r-- | include/protocol.h | 4 | ||||
-rw-r--r-- | modules/protocol/inspircd.cpp | 7 | ||||
-rw-r--r-- | src/process.cpp | 16 |
3 files changed, 17 insertions, 10 deletions
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<Anope::string> &ta bool IRCDProto::Format(Anope::string &message, const Anope::map<Anope::string> &tags, const MessageSource &source, const Anope::string &command, const std::vector<Anope::string> ¶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()) |