{
CHANNEL *chan;
CLIENT *target, *from;
+ const char *colon_if_necessary;
bool remember = false;
assert( Client != NULL );
LogDebug("User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask(from), Req->argv[0], Req->argv[1]);
+
+ /*
+ * RFC 2812 says:
+ * 'There is no requirement that the channel [..] must exist or be a valid channel'
+ * The problem with this is that this allows the "channel" to contain spaces,
+ * in which case we must prefix its name with a colon to make it clear that
+ * it is only a single argument.
+ */
+ colon_if_necessary = strchr(Req->argv[1], ' ') ? ":":"";
/* Inform target client */
- IRC_WriteStrClientPrefix(target, from, "INVITE %s %s", Req->argv[0], Req->argv[1]);
+ IRC_WriteStrClientPrefix(target, from, "INVITE %s %s%s", Req->argv[0],
+ colon_if_necessary, Req->argv[1]);
if (Client_Conn(target) > NONE) {
/* The target user is local, so we have to send the status code */
if (!IRC_WriteStrClientPrefix(from, target, RPL_INVITING_MSG,
- Client_ID(from), Req->argv[0], Req->argv[1]))
+ Client_ID(from), Req->argv[0], colon_if_necessary, Req->argv[1]))
return DISCONNECTED;
if (strchr(Client_Modes(target), 'a') &&
#define RPL_NOTOPIC_MSG "331 %s %s :No topic is set"
#define RPL_TOPIC_MSG "332 %s %s :%s"
#define RPL_TOPICSETBY_MSG "333 %s %s %s %u"
-#define RPL_INVITING_MSG "341 %s %s %s"
+#define RPL_INVITING_MSG "341 %s %s %s%s"
#define RPL_INVITELIST_MSG "346 %s %s %s"
#define RPL_ENDOFINVITELIST_MSG "347 %s %s :End of channel invite list"
#define RPL_VERSION_MSG "351 %s %s-%s.%s %s :%s"