]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Invite: prefix last argument with colon when necessary.
authorDana Dahlstrom <dana+ngIRCd@cs.ucsd.edu>
Sun, 4 May 2008 21:20:05 +0000 (23:20 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 5 May 2008 14:12:41 +0000 (16:12 +0200)
src/ngircd/irc-op.c
src/ngircd/messages.h

index 715323be3ddd0f947079bdb879b494ca674ab3a4..f1ebc79236c5da35155c7a7b426596535969e57c 100644 (file)
@@ -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') &&
index b42e38beb2c08ca0fd1adbfc9208530b854c60ae..b8090d438e3e65fb698463b71849be67980bf0ef 100644 (file)
@@ -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"