summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channel.c41
-rw-r--r--src/channel_mode.c3
-rw-r--r--src/numeric.c4
3 files changed, 39 insertions, 9 deletions
diff --git a/src/channel.c b/src/channel.c
index efc64d1..c3967d5 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -547,11 +547,7 @@ const char *
get_member_status(const struct Membership *ms, int combine)
{
static char buffer[4];
- char *p = NULL;
-
- if (ms == NULL)
- return "";
- p = buffer;
+ char *p = buffer;
if (ms->flags & CHFL_CHANOP)
{
@@ -697,6 +693,35 @@ find_channel_link(struct Client *client_p, struct Channel *chptr)
return NULL;
}
+/*
+ * Basically the same functionality as in bahamut
+ */
+static int
+msg_has_ctrls(const char *message)
+{
+ const unsigned char *p = (const unsigned char *)message;
+
+ for (; *p; ++p)
+ {
+ if (*p > 31 || *p == 1)
+ continue;
+
+ if (*p == 27)
+ {
+ if (*(p + 1) == '$' ||
+ *(p + 1) == '(')
+ {
+ ++p;
+ continue;
+ }
+ }
+
+ return 1;
+ }
+
+ return 0;
+}
+
/*!
* \param chptr pointer to Channel struct
* \param source_p pointer to Client struct
@@ -706,7 +731,8 @@ find_channel_link(struct Client *client_p, struct Channel *chptr)
* ERR_CANNOTSENDTOCHAN or ERR_NEEDREGGEDNICK if they cannot send to channel\n
*/
int
-can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms)
+can_send(struct Channel *chptr, struct Client *source_p,
+ struct Membership *ms, const char *message)
{
struct MaskItem *conf = NULL;
@@ -750,6 +776,9 @@ can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms)
if ((chptr->mode.mode & MODE_REGONLY) && !HasUMode(source_p, UMODE_REGISTERED))
return ERR_NEEDREGGEDNICK;
+ if ((chptr->mode.mode & MODE_NOCTRL) && msg_has_ctrls(message))
+ return ERR_NOCTRLSONCHAN;
+
return CAN_SEND_NONOP;
}
diff --git a/src/channel_mode.c b/src/channel_mode.c
index 2a21b76..d1e83c5 100644
--- a/src/channel_mode.c
+++ b/src/channel_mode.c
@@ -321,6 +321,7 @@ del_id(struct Channel *chptr, char *banid, int type)
}
const struct mode_letter chan_modes[] = {
+ { MODE_NOCTRL, 'c' },
{ MODE_INVITEONLY, 'i' },
{ MODE_MODERATED, 'm' },
{ MODE_NOPRIVMSGS, 'n' },
@@ -1429,7 +1430,7 @@ static struct ChannelMode ModeTable[255] =
{chm_nosuch, NULL},
{chm_nosuch, NULL}, /* a */
{chm_ban, NULL}, /* b */
- {chm_nosuch, NULL}, /* c */
+ {chm_simple, (void *) MODE_NOCTRL}, /* c */
{chm_nosuch, NULL}, /* d */
{chm_except, NULL}, /* e */
{chm_nosuch, NULL}, /* f */
diff --git a/src/numeric.c b/src/numeric.c
index b7fee5b..b1ee134 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -31,7 +31,7 @@ static const char *replies[] = {
/* 001 RPL_WELCOME */ ":%s 001 %s :Welcome to the %s Internet Relay Chat Network %s!%s@%s",
/* 002 RPL_YOURHOST */ ":%s 002 %s :Your host is %s, running version %s",
/* 003 RPL_CREATED */ ":%s 003 %s :This server was created %s",
-/* 004 RPL_MYINFO */ ":%s 004 %s %s %s %s biklmnoprstveIORS bkloveI",
+/* 004 RPL_MYINFO */ ":%s 004 %s %s %s %s bciklmnoprstveIORS bkloveI",
/* 005 RPL_ISUPPORT */ ":%s 005 %s %s :are supported by this server",
/* 006 */ NULL,
/* 007 */ NULL,
@@ -435,7 +435,7 @@ static const char *replies[] = {
/* 405 ERR_TOOMANYCHANNELS */ ":%s 405 %s %s :You have joined too many channels",
/* 406 ERR_WASNOSUCHNICK */ ":%s 406 %s %s :There was no such nickname",
/* 407 ERR_TOOMANYTARGETS */ ":%s 407 %s %s :Too many recipients. Only %d processed",
-/* 408 */ NULL,
+/* 408 ERR_NOCTRLSONCHAN*/ ":%s 408 %s %s :You cannot use control codes on this channel. Not sent: %s",
/* 409 ERR_NOORIGIN */ ":%s 409 %s :No origin specified",
/* 410 ERR_INVALIDCAPCMD */ ":%s 410 %s %s :Invalid CAP subcommand",
/* 411 ERR_NORECIPIENT */ ":%s 411 %s :No recipient given (%s)",