Invite: prefix last argument with colon when necessary.

This commit is contained in:
Dana Dahlstrom 2008-05-04 23:20:05 +02:00 committed by Florian Westphal
parent c63d8fd051
commit 97cc58fb13
2 changed files with 14 additions and 3 deletions

View 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') &&

View 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"