Make blockcolor only block known formatting codes.

This commit is contained in:
Sadie Powell 2024-08-30 17:00:22 +01:00
parent babb39cb17
commit ca0ea6e3d0

View File

@ -65,9 +65,25 @@ public:
if (!details.IsCTCP(ctcpname, message))
message = details.text;
for (const auto chr : message)
auto it = std::find_if(message.begin(), message.end(), [](const char& chr)
{
if (static_cast<unsigned char>(chr) < 32)
switch (chr)
{
case '\x02': // Bold
case '\x03': // Color
case '\x04': // Hex Color
case '\x1D': // Italic
case '\x11': // Monospace
case '\x16': // Reverse
case '\x1E': // Strikethrough
case '\x1F': // Underline
case '\x0F': // Reset
return true;
}
return false;
});
if (it != message.end())
{
if (modeset)
user->WriteNumeric(Numerics::CannotSendTo(c, "messages containing formatting characters", &bc));
@ -77,7 +93,6 @@ public:
}
}
}
}
return MOD_RES_PASSTHRU;
}
};