From 155eda45e862f42a0b9444d615002deda461328d Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 14 Mar 2014 18:40:40 +0100 Subject: [PATCH] Don't always add a colon to custom commands The IRC spec mandates that spaces be used as separators between the arguments for a command. However, the last parameter may itself contain spaces, and to allow this, one can prefix that argument with a colon. Instead of checking if the colon is needed, Quassel just always added a colon to the last argument, which usually works fine. However, it broke some uses of custom server commands. This fix now checks if the last argument contains a space or starts with a colon (which then needs to be escaped), and leaves it alone otherwise. Fixes #1173 - thanks to Gunnar Beutner for providing the patch. --- src/core/corenetwork.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 798f27c8..954565cf 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -264,11 +264,14 @@ void CoreNetwork::putCmd(const QString &cmd, const QList ¶ms, co msg += ":" + prefix + " "; msg += cmd.toUpper().toAscii(); - for (int i = 0; i < params.size() - 1; i++) { - msg += " " + params[i]; + for (int i = 0; i < params.size(); i++) { + msg += " "; + + if (i == params.size() - 1 && (params[i].contains(' ') || (!params[i].isEmpty() && params[i][0] == ':'))) + msg += ":"; + + msg += params[i]; } - if (!params.isEmpty()) - msg += " :" + params.last(); putRawLine(msg); } -- 2.20.1