about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDana Dahlstrom <dana+ngIRCd@cs.ucsd.edu>2008-05-04 23:20:05 +0200
committerFlorian Westphal <fw@strlen.de>2008-05-05 16:12:41 +0200
commit97cc58fb13674fdaf55782ff2277262e9cad94e7 (patch)
tree0c3c23b1284ba39129dcfd385d51842772f243e3
parentc63d8fd051b9d1e9c8dfa64424b9f557968c4513 (diff)
downloadngircd-97cc58fb13674fdaf55782ff2277262e9cad94e7.tar.gz
ngircd-97cc58fb13674fdaf55782ff2277262e9cad94e7.zip
Invite: prefix last argument with colon when necessary.
-rw-r--r--src/ngircd/irc-op.c15
-rw-r--r--src/ngircd/messages.h2
2 files changed, 14 insertions, 3 deletions
diff --git a/src/ngircd/irc-op.c b/src/ngircd/irc-op.c
index 715323be..f1ebc792 100644
--- a/src/ngircd/irc-op.c
+++ b/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') &&
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index b42e38be..b8090d43 100644
--- a/src/ngircd/messages.h
+++ b/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"