Commit Diff


commit - c63d8fd051b9d1e9c8dfa64424b9f557968c4513
commit + 97cc58fb13674fdaf55782ff2277262e9cad94e7
blob - 715323be3ddd0f947079bdb879b494ca674ab3a4
blob + f1ebc79236c5da35155c7a7b426596535969e57c
--- src/ngircd/irc-op.c
+++ src/ngircd/irc-op.c
@@ -130,6 +130,7 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
 {
 	CHANNEL *chan;
 	CLIENT *target, *from;
+	const char *colon_if_necessary;
 	bool remember = false;
 
 	assert( Client != NULL );
@@ -186,13 +187,23 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
 
 	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') &&
blob - b42e38beb2c08ca0fd1adbfc9208530b854c60ae
blob + b8090d438e3e65fb698463b71849be67980bf0ef
--- src/ngircd/messages.h
+++ src/ngircd/messages.h
@@ -65,7 +65,7 @@
 #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"