From 0e14adcb0fe40496e9fcaa17207b1099b1ec330d Mon Sep 17 00:00:00 2001 From: genius3000 Date: Wed, 26 Jul 2017 03:01:03 -0600 Subject: [PATCH] Fix sending incorrect RLines to InspIRCd Currently a Regex AKILL is sent with a malformed mask to InspIRCd as an RLine. InspIRCd expects a mask of 'n!u@h\sr', so we need to remove the enclosing slashes (/.../), change the '#' separator to '\s', and change any literal spaces to '\s' and then it creates a proper RLine. --- modules/protocol/inspircd12.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 0d012e214..609ce36f3 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -105,13 +105,21 @@ class InspIRCd12Proto : public IRCDProto void SendAkillDel(const XLine *x) anope_override { - /* InspIRCd may support regex bans */ + /* InspIRCd may support regex bans + * Mask is expected in format: 'n!u@h\sr' and spaces as '\s' + * We remove the '//' and replace '#' and any ' ' with '\s' + */ if (x->IsRegex() && Servers::Capab.count("RLINE")) { Anope::string mask = x->mask; - size_t h = x->mask.find('#'); + if (mask.length() >= 2 && mask[0] == '/' && mask[mask.length() - 1] == '/') + mask = mask.substr(1, mask.length() - 2); + size_t h = mask.find('#'); if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); + { + mask = mask.replace(h, 1, "\\s"); + mask = mask.replace_all_cs(" ", "\\s"); + } SendDelLine("R", mask); return; } @@ -168,13 +176,21 @@ class InspIRCd12Proto : public IRCDProto if (timeleft > 172800 || !x->expires) timeleft = 172800; - /* InspIRCd may support regex bans, if they do we can send this and forget about it */ + /* InspIRCd may support regex bans, if they do we can send this and forget about it + * Mask is expected in format: 'n!u@h\sr' and spaces as '\s' + * We remove the '//' and replace '#' and any ' ' with '\s' + */ if (x->IsRegex() && Servers::Capab.count("RLINE")) { Anope::string mask = x->mask; - size_t h = x->mask.find('#'); + if (mask.length() >= 2 && mask[0] == '/' && mask[mask.length() - 1] == '/') + mask = mask.substr(1, mask.length() - 2); + size_t h = mask.find('#'); if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); + { + mask = mask.replace(h, 1, "\\s"); + mask = mask.replace_all_cs(" ", "\\s"); + } SendAddLine("R", mask, timeleft, x->by, x->GetReason()); return; }