summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2025-04-22 17:36:26 +0100
committerSadie Powell <sadie@witchery.services>2025-04-22 18:16:31 +0100
commitf3629598347763c984d03ee70235133c45dd9908 (patch)
tree9aa5190273a40005a4c730c06258b1ee3ae703c7
parentf5a85c69d225edaed4e11eb4c2b27d66ebc5195e (diff)
Fix splitting in the middle of some command names.
-rw-r--r--include/anope.h8
-rw-r--r--modules/botserv/bs_badwords.cpp2
-rw-r--r--modules/chanserv/cs_flags.cpp2
-rw-r--r--modules/chanserv/cs_log.cpp4
-rw-r--r--modules/chanserv/cs_mode.cpp6
-rw-r--r--modules/chanserv/cs_seen.cpp2
-rw-r--r--modules/chanserv/cs_topic.cpp2
-rw-r--r--modules/chanserv/cs_xop.cpp22
-rw-r--r--modules/help.cpp2
-rw-r--r--modules/memoserv/ms_rsend.cpp2
-rw-r--r--modules/memoserv/ms_send.cpp2
-rw-r--r--modules/nickserv/nickserv.cpp2
-rw-r--r--modules/operserv/os_shutdown.cpp2
-rw-r--r--modules/operserv/os_sxline.cpp24
-rw-r--r--src/bots.cpp5
-rw-r--r--src/command.cpp6
16 files changed, 49 insertions, 44 deletions
diff --git a/include/anope.h b/include/anope.h
index 9c109d9ee..618592090 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -222,6 +222,14 @@ namespace Anope
inline bool is_pos_number_only() const { return this->find_first_not_of("0123456789.") == npos; }
/**
+ * In IRC messages we use a substitute (ASCII 0x1A) instead of a space
+ * (ASCII 0x20) so it doesn't get line wrapped when put into a message.
+ * The line wrapper will convert this to a space before it is sent to
+ * clients.
+ */
+ inline Anope::string nobreak() const { return this->replace_all_cs("\x20", "\x1A"); }
+
+ /**
* Replace parts of the string.
*/
inline string replace(size_type pos, size_type n, const string &_str) { return string(this->_string.replace(pos, n, _str._string)); }
diff --git a/modules/botserv/bs_badwords.cpp b/modules/botserv/bs_badwords.cpp
index d50ca0f95..48d101c56 100644
--- a/modules/botserv/bs_badwords.cpp
+++ b/modules/botserv/bs_badwords.cpp
@@ -466,7 +466,7 @@ public:
"bad words list."
),
source.service->GetQueryCommand("generic/help").c_str(),
- source.command.c_str());
+ source.command.nobreak().c_str());
return true;
}
};
diff --git a/modules/chanserv/cs_flags.cpp b/modules/chanserv/cs_flags.cpp
index e0de2c81e..080e8498c 100644
--- a/modules/chanserv/cs_flags.cpp
+++ b/modules/chanserv/cs_flags.cpp
@@ -464,7 +464,7 @@ public:
"\n\n"
"The available flags are:"
),
- source.command.c_str());
+ source.command.nobreak().c_str());
typedef std::multimap<char, Anope::string, ci::less> reverse_map;
reverse_map reverse;
diff --git a/modules/chanserv/cs_log.cpp b/modules/chanserv/cs_log.cpp
index f50cbf517..b33a1bf44 100644
--- a/modules/chanserv/cs_log.cpp
+++ b/modules/chanserv/cs_log.cpp
@@ -292,8 +292,8 @@ public:
" Would message any channel operators whenever someone used the "
"ACCESS command on ChanServ on the channel."
),
- source.command.upper().c_str(),
- source.command.upper().c_str());
+ source.command.nobreak().c_str(),
+ source.command.nobreak().c_str());
return true;
}
diff --git a/modules/chanserv/cs_mode.cpp b/modules/chanserv/cs_mode.cpp
index eebc830c6..f7f417d28 100644
--- a/modules/chanserv/cs_mode.cpp
+++ b/modules/chanserv/cs_mode.cpp
@@ -800,9 +800,9 @@ public:
"any mode name. Examples include bans, excepts, inviteoverrides, ops, halfops, and voices. If \037what\037 "
"is not given then all basic modes are removed."
),
- source.command.upper().c_str(),
- source.command.upper().c_str(),
- source.command.upper().c_str());
+ source.command.nobreak().c_str(),
+ source.command.nobreak().c_str(),
+ source.command.nobreak().c_str());
return true;
}
};
diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp
index 31c5e6b88..ec90206e1 100644
--- a/modules/chanserv/cs_seen.cpp
+++ b/modules/chanserv/cs_seen.cpp
@@ -191,7 +191,7 @@ public:
" %s\032CLEAR\03230m\n"
" Will remove all entries that were added within the last 30 minutes."
),
- source.command.c_str());
+ source.command.nobreak().c_str());
return true;
}
};
diff --git a/modules/chanserv/cs_topic.cpp b/modules/chanserv/cs_topic.cpp
index e1aa98e99..fd5d61b2d 100644
--- a/modules/chanserv/cs_topic.cpp
+++ b/modules/chanserv/cs_topic.cpp
@@ -75,7 +75,7 @@ public:
"last user leaves the channel, and will be restored the "
"next time the channel is created."
),
- source.command.c_str(),
+ source.command.nobreak().c_str(),
source.service->nick.c_str());
return true;
}
diff --git a/modules/chanserv/cs_xop.cpp b/modules/chanserv/cs_xop.cpp
index ffdf46488..feddbacd7 100644
--- a/modules/chanserv/cs_xop.cpp
+++ b/modules/chanserv/cs_xop.cpp
@@ -234,7 +234,7 @@ private:
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask;
FOREACH_MOD(OnAccessAdd, (ci, source, acc));
- source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask().c_str(), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask().c_str(), ci->name.c_str(), source.command.nobreak().c_str());
}
void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params)
@@ -256,7 +256,7 @@ private:
if (!ci->GetAccessCount())
{
- source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.nobreak().c_str());
return;
}
@@ -315,11 +315,11 @@ private:
~XOPDelCallback() override
{
if (!deleted)
- source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.nobreak().c_str());
else
{
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << nicks;
- source.Reply(deleted, N_("Deleted %d entry from %s %s list.", "Deleted %d entries from %s %s list."), deleted, ci->name.c_str(), source.command.c_str());
+ source.Reply(deleted, N_("Deleted %d entry from %s %s list.", "Deleted %d entries from %s %s list."), deleted, ci->name.c_str(), source.command.nobreak().c_str());
}
}
@@ -360,7 +360,7 @@ private:
{
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->Mask();
- source.Reply(_("\002%s\002 deleted from %s %s list."), a->Mask().c_str(), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 deleted from %s %s list."), a->Mask().c_str(), ci->name.c_str(), source.command.nobreak().c_str());
ci->EraseAccess(i);
FOREACH_MOD(OnAccessDel, (ci, source, a));
@@ -370,7 +370,7 @@ private:
}
}
- source.Reply(_("\002%s\002 not found on %s %s list."), mask.c_str(), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 not found on %s %s list."), mask.c_str(), ci->name.c_str(), source.command.nobreak().c_str());
}
}
@@ -389,7 +389,7 @@ private:
if (!ci->GetAccessCount())
{
- source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.nobreak().c_str());
return;
}
@@ -454,7 +454,7 @@ private:
std::vector<Anope::string> replies;
list.Process(replies);
- source.Reply(_("%s list for %s"), source.command.c_str(), ci->name.c_str());
+ source.Reply(_("%s list for %s"), source.command.nobreak().c_str(), ci->name.c_str());
for (const auto &reply : replies)
source.Reply(reply);
}
@@ -470,7 +470,7 @@ private:
if (!ci->GetAccessCount())
{
- source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("%s %s list is empty."), ci->name.c_str(), source.command.nobreak().c_str());
return;
}
@@ -495,7 +495,7 @@ private:
FOREACH_MOD(OnAccessClear, (ci, source));
- source.Reply(_("Channel %s %s list has been cleared."), ci->name.c_str(), source.command.c_str());
+ source.Reply(_("Channel %s %s list has been cleared."), ci->name.c_str(), source.command.nobreak().c_str());
}
public:
@@ -509,7 +509,7 @@ public:
const Anope::string GetDesc(CommandSource &source) const override
{
- return Anope::printf(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.upper().c_str());
+ return Anope::printf(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.nobreak().c_str());
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
diff --git a/modules/help.cpp b/modules/help.cpp
index bd29c01e5..9fae2d43f 100644
--- a/modules/help.cpp
+++ b/modules/help.cpp
@@ -119,7 +119,7 @@ public:
if (!groups.empty())
{
source.Reply(" ");
- source.Reply(_("Use the \002%s\032ALL\002 command to list all commands and their descriptions."), source_command.c_str());
+ source.Reply(_("Use the \002%s\032ALL\002 command to list all commands and their descriptions."), source.command.nobreak().c_str());
}
}
else
diff --git a/modules/memoserv/ms_rsend.cpp b/modules/memoserv/ms_rsend.cpp
index 22b27a4f4..ea5d00234 100644
--- a/modules/memoserv/ms_rsend.cpp
+++ b/modules/memoserv/ms_rsend.cpp
@@ -59,7 +59,7 @@ public:
{
auto lastmemosend = source.GetUser() ? source.GetUser()->lastmemosend : 0;
auto waitperiod = (lastmemosend + Config->GetModule("memoserv").Get<unsigned long>("senddelay")) - Anope::CurTime;
- source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.c_str());
+ source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.nobreak().c_str());
}
else if (result == MemoServService::MEMO_TARGET_FULL)
source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str());
diff --git a/modules/memoserv/ms_send.cpp b/modules/memoserv/ms_send.cpp
index 8e348b949..c9ed94726 100644
--- a/modules/memoserv/ms_send.cpp
+++ b/modules/memoserv/ms_send.cpp
@@ -58,7 +58,7 @@ public:
{
auto lastmemosend = source.GetUser() ? source.GetUser()->lastmemosend : 0;
auto waitperiod = (lastmemosend + Config->GetModule("memoserv").Get<unsigned long>("senddelay")) - Anope::CurTime;
- source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.c_str());
+ source.Reply(_("Please wait %s before using the %s command again."), Anope::Duration(waitperiod, source.GetAccount()).c_str(), source.command.nobreak().c_str());
}
else if (result == MemoServService::MEMO_TARGET_FULL)
source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str());
diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp
index 8c77019ab..274189792 100644
--- a/modules/nickserv/nickserv.cpp
+++ b/modules/nickserv/nickserv.cpp
@@ -525,7 +525,7 @@ public:
),
NickServ->nick.c_str(),
NickServ->GetQueryCommand().c_str(),
- NickServ->GetQueryCommand({}, source.command.c_str()).c_str());
+ NickServ->GetQueryCommand({}, source.command).c_str());
}
return EVENT_CONTINUE;
}
diff --git a/modules/operserv/os_shutdown.cpp b/modules/operserv/os_shutdown.cpp
index 971c0525f..dc3624242 100644
--- a/modules/operserv/os_shutdown.cpp
+++ b/modules/operserv/os_shutdown.cpp
@@ -21,7 +21,7 @@ namespace
if (params.empty())
cmd->OnSyntaxError(source, source.command);
else if (!params[0].equals_cs(Config->GetBlock("networkinfo").Get<Anope::string>("networkname")))
- source.Reply(_("The network name you specified is incorrect. Did you mean to run %s on a different network?"), source.command.c_str());
+ source.Reply(_("The network name you specified is incorrect. Did you mean to run %s on a different network?"), source.command.nobreak().c_str());
else
return true; // Name was specified correctly
return false; // Network name was wrong or not specified.
diff --git a/modules/operserv/os_sxline.cpp b/modules/operserv/os_sxline.cpp
index 0b85d9d16..f19cc529c 100644
--- a/modules/operserv/os_sxline.cpp
+++ b/modules/operserv/os_sxline.cpp
@@ -26,9 +26,9 @@ public:
~SXLineDelCallback() override
{
if (deleted)
- source.Reply(deleted, N_("Deleted %d entry from the %s list.", "Deleted %d entries from the %s list."), deleted, source.command.c_str());
+ source.Reply(deleted, N_("Deleted %d entry from the %s list.", "Deleted %d entries from the %s list."), deleted, source.command.nobreak().c_str());
else
- source.Reply(_("No matching entries on the %s list."), source.command.c_str());
+ source.Reply(_("No matching entries on the %s list."), source.command.nobreak().c_str());
}
void HandleNumber(unsigned number) override
@@ -66,7 +66,7 @@ private:
if (!this->xlm() || this->xlm()->GetList().empty())
{
- source.Reply(_("%s list is empty."), source.command.c_str());
+ source.Reply(_("%s list is empty."), source.command.nobreak().c_str());
return;
}
@@ -89,14 +89,14 @@ private:
if (!x)
{
- source.Reply(_("\002%s\002 not found on the %s list."), mask.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 not found on the %s list."), mask.c_str(), source.command.nobreak().c_str());
return;
}
FOREACH_MOD(OnDelXLine, (source, x, this->xlm()));
SXLineDelCallback::DoDel(this->xlm(), source, x);
- source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.nobreak().c_str());
Log(LOG_ADMIN, source, this) << "to remove " << mask << " from the list";
}
@@ -110,7 +110,7 @@ private:
{
if (!this->xlm() || this->xlm()->GetList().empty())
{
- source.Reply(_("%s list is empty."), source.command.c_str());
+ source.Reply(_("%s list is empty."), source.command.nobreak().c_str());
return;
}
@@ -175,10 +175,10 @@ private:
}
if (list.IsEmpty())
- source.Reply(_("No matching entries on the %s list."), source.command.c_str());
+ source.Reply(_("No matching entries on the %s list."), source.command.nobreak().c_str());
else
{
- source.Reply(_("Current %s list:"), source.command.c_str());
+ source.Reply(_("Current %s list:"), source.command.nobreak().c_str());
std::vector<Anope::string> replies;
list.Process(replies);
@@ -218,7 +218,7 @@ private:
}
Log(LOG_ADMIN, source, this) << "to CLEAR the list";
- source.Reply(_("The %s list has been cleared."), source.command.c_str());
+ source.Reply(_("The %s list has been cleared."), source.command.nobreak().c_str());
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
@@ -231,7 +231,7 @@ public:
const Anope::string GetDesc(CommandSource &source) const override
{
- return Anope::printf(Language::Translate(source.GetAccount(), _("Manipulate the %s list")), source.command.upper().c_str());
+ return Anope::printf(Language::Translate(source.GetAccount(), _("Manipulate the %s list")), source.command.nobreak().c_str());
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -415,7 +415,7 @@ class CommandOSSNLine final
this->xlm()->Send(NULL, x);
}
- source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.nobreak().c_str());
Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
@@ -654,7 +654,7 @@ class CommandOSSQLine final
this->xlm()->Send(NULL, x);
}
- source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.c_str());
+ source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.nobreak().c_str());
Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]";
if (Anope::ReadOnly)
source.Reply(READ_ONLY_MODE);
diff --git a/src/bots.cpp b/src/bots.cpp
index 33afc7595..01da4b888 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -299,10 +299,7 @@ Anope::string BotInfo::GetQueryCommand(const Anope::string &command, const Anope
if (!extra.empty())
buf.append(" ").append(extra);
- // We use a substitute (ASCII 0x1A) instead of a space (ASCII 0x20) so it
- // doesn't get line wrapped when put into a message. The line wrapper will
- // convert this to a space before it is sent to clients.
- return buf.replace_all_cs("\x20", "\x1A");
+ return buf.nobreak();
}
BotInfo *BotInfo::Find(const Anope::string &nick, bool nick_only)
diff --git a/src/command.cpp b/src/command.cpp
index b688803cc..57fd1cf98 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -171,18 +171,18 @@ void Command::SendSyntax(CommandSource &source)
if (first)
{
first = false;
- source.Reply("%s: \002%s %s\002", prefix.c_str(), source.command.c_str(),
+ source.Reply("%s: \002%s %s\002", prefix.c_str(), source.command.nobreak().c_str(),
Language::Translate(source.GetAccount(), syntax.c_str()));
}
else
{
- source.Reply("%-*s \002%s %s\002", (int)prefix.length(), "", source.command.c_str(),
+ source.Reply("%-*s \002%s %s\002", (int)prefix.length(), "", source.command.nobreak().c_str(),
Language::Translate(source.GetAccount(), syntax.c_str()));
}
}
if (first)
- source.Reply("%s: \002%s\002", prefix.c_str(), source.command.c_str());
+ source.Reply("%s: \002%s\002", prefix.c_str(), source.command.nobreak().c_str());
}
bool Command::AllowUnregistered() const