summaryrefslogtreecommitdiff
path: root/modules/protocol/inspircd12.cpp
diff options
context:
space:
mode:
authorgenius3000 <genius3000@g3k.solutions>2017-07-26 03:01:03 -0600
committergenius3000 <genius3000@g3k.solutions>2017-10-14 08:36:35 -0600
commit0e14adcb0fe40496e9fcaa17207b1099b1ec330d (patch)
tree277a7da2050e9c86a6c37ffcf271a73cddcc3b8e /modules/protocol/inspircd12.cpp
parent3cb9e0b97c15e2d997d519b4bfc1821252c2384d (diff)
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.
Diffstat (limited to 'modules/protocol/inspircd12.cpp')
-rw-r--r--modules/protocol/inspircd12.cpp28
1 files 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;
}