Simplify and improve ANNOY_KICK checks.
The annoy kick code looks for messages that are longer than 12 characters and more than 75% of them are highlighted (eg. bold). The old code counted the whoel message length, so it could be fooled by padding the message with lots of nonprinting control characters. This change makes it count only displaying characters. Also fix the check for beep (it's a single character, not a highlighting toggle, so we just check for one of them), and add a check for the blinking highlight.
This commit is contained in:
@@ -172,7 +172,8 @@ found_auto:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int caps_fucknut (const char *crap)
|
/* Check for more than 75% ALLCAPS */
|
||||||
|
static int annoy_caps(const char *crap)
|
||||||
{
|
{
|
||||||
int total = 0, allcaps = 0;
|
int total = 0, allcaps = 0;
|
||||||
/* removed from ComStud client */
|
/* removed from ComStud client */
|
||||||
@@ -186,44 +187,36 @@ static int caps_fucknut (const char *crap)
|
|||||||
}
|
}
|
||||||
crap++;
|
crap++;
|
||||||
}
|
}
|
||||||
if (total > 12)
|
return total > 12 && (double)allcaps / total >= 0.75;
|
||||||
{
|
|
||||||
if ( ((unsigned int)(((float) allcaps / (float) total) * 100) >= 75))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int char_fucknut (const char *crap, char looking, int max)
|
/* Check for more than 75% of printable chars highlighted */
|
||||||
|
static int annoy_hl(const char *crap, char hl_tog)
|
||||||
{
|
{
|
||||||
int total = strlen(crap), allchar = 0;
|
int total = 0, all_hl = 0, in_highlight = 0;
|
||||||
|
|
||||||
while (*crap)
|
while (*crap)
|
||||||
{
|
{
|
||||||
if ((*crap == looking))
|
if (*crap == hl_tog)
|
||||||
|
in_highlight = !in_highlight;
|
||||||
|
|
||||||
|
if (isgraph((unsigned char)*crap))
|
||||||
{
|
{
|
||||||
crap++;
|
total++;
|
||||||
while(*crap && *crap != looking)
|
if (in_highlight)
|
||||||
{
|
all_hl++;
|
||||||
allchar++;
|
}
|
||||||
|
|
||||||
crap++;
|
crap++;
|
||||||
}
|
}
|
||||||
}
|
return total > 12 && (double)all_hl / total >= 0.75;
|
||||||
if (*crap)
|
|
||||||
crap++;
|
|
||||||
}
|
|
||||||
if (total > 12)
|
|
||||||
{
|
|
||||||
if ( ((unsigned int)(((float) allchar / (float) total) * 100)) >= 75)
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int annoy_kicks(int list_type, char *to, char *from, char *ptr, NickList *nick)
|
int annoy_kicks(int list_type, char *to, char *from, char *ptr, NickList *nick)
|
||||||
{
|
{
|
||||||
int kick_em = 0;
|
int kick_em = 0;
|
||||||
ChannelList *chan;
|
ChannelList *chan;
|
||||||
|
|
||||||
if (nick && (nick->userlist && nick->userlist->flags))
|
if (nick && (nick->userlist && nick->userlist->flags))
|
||||||
return 0;
|
return 0;
|
||||||
if (!check_channel_match(get_string_var(PROTECT_CHANNELS_VAR), to) || !are_you_opped(to))
|
if (!check_channel_match(get_string_var(PROTECT_CHANNELS_VAR), to) || !are_you_opped(to))
|
||||||
@@ -233,17 +226,19 @@ ChannelList *chan;
|
|||||||
if (get_cset_int_var(chan->csets, ANNOY_KICK_CSET) && !nick_isop(nick))
|
if (get_cset_int_var(chan->csets, ANNOY_KICK_CSET) && !nick_isop(nick))
|
||||||
{
|
{
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
if (char_fucknut(ptr, '\002', 12))
|
if (annoy_hl(ptr, BOLD_TOG))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s",to, from, "autokick for \002bold\002");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " BOLD_TOG_STR "bold" BOLD_TOG_STR);
|
||||||
else if (char_fucknut(ptr, '\007', 1))
|
else if (strchr(ptr, '\007'))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for beeping");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for beeping");
|
||||||
else if (char_fucknut(ptr, '\003', 12))
|
else if (annoy_hl(ptr, '\003'))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for \037mirc color\037");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " UND_TOG_STR "mirc color" UND_TOG_STR);
|
||||||
else if (char_fucknut(ptr, '\037', 0))
|
else if (annoy_hl(ptr, UND_TOG))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for \037underline\037");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " UND_TOG_STR "underline" UND_TOG_STR);
|
||||||
else if (char_fucknut(ptr, '\026', 12))
|
else if (annoy_hl(ptr, REV_TOG))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for \026inverse\026");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " REV_TOG_STR "inverse" REV_TOG_STR);
|
||||||
else if (caps_fucknut(ptr))
|
else if (annoy_hl(ptr, BLINK_TOG))
|
||||||
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for " BLINK_TOG_STR "flashing" BLINK_TOG_STR);
|
||||||
|
else if (annoy_caps(ptr))
|
||||||
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for CAPS LOCK");
|
malloc_sprintf(&buffer, "KICK %s %s :%s", to, from, "autokick for CAPS LOCK");
|
||||||
else if (strstr(ptr, "0000027fed"))
|
else if (strstr(ptr, "0000027fed"))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user