From 6eb033605c5574eadbb13f6f641d3829a195859e Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 31 Mar 2012 22:18:15 -0500 Subject: [PATCH] Check for empty string after permutation hooks have run. --- modules/core/m_message.c | 62 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 21d3578e..f99d8959 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -494,14 +494,6 @@ msg_channel(enum message_type msgtype, rb_strlcpy(text2, text, BUFSIZE); strip_colour(text2); text = text2; - if (EmptyString(text)) - { - /* could be empty after colour stripping and - * that would cause problems later */ - if(msgtype != MESSAGE_TYPE_NOTICE) - sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); - return; - } } hdata.msgtype = msgtype; @@ -518,6 +510,16 @@ msg_channel(enum message_type msgtype, if (hdata.approved != 0) return; + /* hook may have reduced the string to nothing. */ + if (EmptyString(text)) + { + /* could be empty after colour stripping and + * that would cause problems later */ + if(msgtype != MESSAGE_TYPE_NOTICE) + sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); + return; + } + /* chanops and voiced can flood their own channel with impunity */ if((result = can_send(chptr, source_p, NULL))) { @@ -597,14 +599,6 @@ msg_channel_opmod(enum message_type msgtype, rb_strlcpy(text2, text, BUFSIZE); strip_colour(text2); text = text2; - if (EmptyString(text)) - { - /* could be empty after colour stripping and - * that would cause problems later */ - if(msgtype != MESSAGE_TYPE_NOTICE) - sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); - return; - } } hdata.msgtype = msgtype; @@ -621,6 +615,16 @@ msg_channel_opmod(enum message_type msgtype, if (hdata.approved != 0) return; + /* hook may have reduced the string to nothing. */ + if (EmptyString(text)) + { + /* could be empty after colour stripping and + * that would cause problems later */ + if(msgtype != MESSAGE_TYPE_NOTICE) + sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); + return; + } + if(chptr->mode.mode & MODE_OPMODERATE && (!(chptr->mode.mode & MODE_NOPRIVMSGS) || IsMember(source_p, chptr))) @@ -684,14 +688,6 @@ msg_channel_flags(enum message_type msgtype, struct Client *client_p, rb_strlcpy(text2, text, BUFSIZE); strip_colour(text2); text = text2; - if (EmptyString(text)) - { - /* could be empty after colour stripping and - * that would cause problems later */ - if(msgtype != MESSAGE_TYPE_NOTICE) - sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); - return; - } } hdata.msgtype = msgtype; @@ -708,6 +704,15 @@ msg_channel_flags(enum message_type msgtype, struct Client *client_p, if (hdata.approved != 0) return; + if (EmptyString(text)) + { + /* could be empty after colour stripping and + * that would cause problems later */ + if(msgtype != MESSAGE_TYPE_NOTICE) + sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); + return; + } + if (msgtype != MESSAGE_TYPE_NOTICE && *text == '\001' && strncasecmp(text + 1, "ACTION ", 7)) { @@ -856,6 +861,15 @@ msg_client(enum message_type msgtype, if (hdata.approved != 0) return; + if (EmptyString(text)) + { + /* could be empty after colour stripping and + * that would cause problems later */ + if(msgtype != MESSAGE_TYPE_NOTICE) + sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name); + return; + } + /* XXX Controversial? allow opers always to send through a +g */ if(!IsServer(source_p) && (IsSetCallerId(target_p) || (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])))