diff options
-rw-r--r-- | data/chanserv.example.conf | 6 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | modules/commands/cs_akick.cpp | 3 | ||||
-rw-r--r-- | modules/commands/cs_ban.cpp | 5 | ||||
-rw-r--r-- | modules/commands/cs_kick.cpp | 5 | ||||
-rw-r--r-- | src/config.cpp | 1 |
6 files changed, 20 insertions, 2 deletions
diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf index 114d1f97e..c570e9185 100644 --- a/data/chanserv.example.conf +++ b/data/chanserv.example.conf @@ -205,6 +205,12 @@ chanserv * services immediately reversing topic changes. */ use_server_side_topiclock = yes + + /* + * The maximum length of the reason field for user commands such as chanserv/kick + * and chanserv/ban. + */ + reasonmax = 200 } /* diff --git a/include/config.h b/include/config.h index 7e19ba32f..b53047a0c 100644 --- a/include/config.h +++ b/include/config.h @@ -443,6 +443,8 @@ class CoreExport ServerConfig bool UseServerSideMLock; /* Use server side topic lock */ bool UseServerSideTopicLock; + /* The max length for reasons (cs_kick, cs_ban, etc) */ + unsigned CSReasonMax; /* Default botmodes on channels, defaults to ao */ Anope::string BotModes; /* How long to wait between connection attempts */ diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 29959bf32..9447b1aed 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -56,6 +56,9 @@ class CommandCSAKick : public Command NickCore *nc = NULL; const AutoKick *akick; + if (reason.length() > Config->CSReasonMax) + reason = reason.substr(0, Config->CSReasonMax); + if (!na) { Anope::string nick, user, host; diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index e857243f9..0fb65ecf6 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -27,7 +27,7 @@ class CommandCSBan : public Command { const Anope::string &chan = params[0]; const Anope::string &target = params[1]; - const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; + Anope::string reason = params.size() > 2 ? params[2] : "Requested"; ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) @@ -42,6 +42,9 @@ class CommandCSBan : public Command AccessGroup u_access = source.AccessFor(ci); + if (reason.length() > Config->CSReasonMax) + reason = reason.substr(0, Config->CSReasonMax); + if (!c) source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); else if (!u_access.HasPriv("BAN")) diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index 4073f3fe8..e02ab5185 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -27,7 +27,7 @@ class CommandCSKick : public Command { const Anope::string &chan = params[0]; const Anope::string &target = params[1]; - const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; + Anope::string reason = params.size() > 2 ? params[2] : "Requested"; User *u = source.GetUser(); ChannelInfo *ci = ChannelInfo::Find(params[0]); @@ -45,6 +45,9 @@ class CommandCSKick : public Command return; } + if (reason.length() > Config->CSReasonMax) + reason = reason.substr(0, Config->CSReasonMax); + AccessGroup u_access = source.AccessFor(ci); if (!u_access.HasPriv("KICK")) diff --git a/src/config.cpp b/src/config.cpp index c78ecb8ed..8078da0ce 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1287,6 +1287,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"chanserv", "require", "", new ValueContainerString(&conf->CSRequire), DT_STRING, NoValidation}, {"chanserv", "use_server_side_mlock", "yes", new ValueContainerBool(&conf->UseServerSideMLock), DT_BOOLEAN, NoValidation}, {"chanserv", "use_server_side_topiclock", "yes", new ValueContainerBool(&conf->UseServerSideTopicLock), DT_BOOLEAN, NoValidation}, + {"chanserv", "reasonmax", "200", new ValueContainerUInt(&conf->CSReasonMax), DT_UINTEGER, NoValidation}, {"memoserv", "name", "", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation}, {"memoserv", "maxmemos", "0", new ValueContainerUInt(&conf->MSMaxMemos), DT_UINTEGER, NoValidation}, {"memoserv", "senddelay", "0", new ValueContainerTime(&conf->MSSendDelay), DT_TIME, NoValidation}, |