From aac9fe1921a1c46aad240aa0fb990e7907782cf0 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 9 Dec 2022 10:17:36 +0000 Subject: Fix sending malformed MOTD and showfile messages to clients. --- src/modules/m_showfile.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/modules/m_showfile.cpp') diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index ba3dc60e1..80dcf95d0 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -60,7 +60,7 @@ class CommandShowFile : public Command user->WriteRemoteNumeric(intronumeric, introtext); for (file_cache::const_iterator i = contents.begin(); i != contents.end(); ++i) - user->WriteRemoteNumeric(textnumeric, InspIRCd::Format(" %s", i->c_str())); + user->WriteRemoteNumeric(textnumeric, *i); if (!endtext.empty() && endnumeric) user->WriteRemoteNumeric(endnumeric, endtext.c_str()); @@ -93,7 +93,17 @@ class CommandShowFile : public Command else if (smethod == "notice") method = SF_NOTICE; - contents = filecontents; + // Process the entry. + contents.clear(); + contents.reserve(filecontents.size()); + for (file_cache::const_iterator it = filecontents.begin(); it != filecontents.end(); ++it) + { + // Some clients can not handle receiving NOTICE/PRIVMSG/RPL_RULES + // with an empty trailing parameter so if a line is empty we + // replace it with a single space. + const std::string& line = *it; + contents.push_back(line.empty() ? " " : line); + } InspIRCd::ProcessColors(contents); } }; -- cgit v1.3.1-10-gc9f91