[Dancer-changes] dancer/src flood.c,1.1.1.1,1.2
Brought to you by:
bagder
|
From: <ho...@us...> - 2003-09-15 18:03:17
|
Update of /cvsroot/dancer/dancer/src
In directory sc8-pr-cvs1:/tmp/cvs-serv21993
Modified Files:
flood.c
Log Message:
When performing checks for uppercase violations, compare percentage against the
string length, excluding colourcodes. This fixes bug# 475631: "Flawed uppercase
and colour check"
Index: flood.c
===================================================================
RCS file: /cvsroot/dancer/dancer/src/flood.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- flood.c 13 Nov 2000 02:42:41 -0000 1.1.1.1
+++ flood.c 15 Sep 2003 18:03:12 -0000 1.2
@@ -140,7 +140,8 @@
void Check(itemguest *g, char *line)
{
long uppers = 0, beeps = 0, colours = 0;
- long length;
+ unsigned long length;
+ long stripped = 0; /* length of line after non-ascii chars have been stripped */
if (NULL == line)
return;
@@ -150,8 +151,15 @@
beeps++;
if (colourcheck && ('\x03' == line[length]) && isdigit(line[length + 1]))
colours++;
- if (uppercheck && isupper(line[length]))
- uppers++;
+ /* If we check for uppercase violations, keep track of the visible length
+ * of the line (as well as uppercase violations) as this is required if we
+ * want to kick uppercase violators that 'hide behind' colourcodes. */
+ if (uppercheck) {
+ if (isupper(line[length]))
+ uppers++;
+ if (isascii(line[length]))
+ stripped++;
+ }
}
if (beeps) {
@@ -163,8 +171,8 @@
if (colours) {
Warning(g, GetDefaultText(msg_colour_users), GetDefaultText(msg_kickmsg_no_colours));
}
- if (uppers && (length > 10)) {
- if (uppers*1000/length > 750) /* This is a serious uppercase violation */
+ if (uppers && (length > 10)) { /* More than 10 total chars in message .. */
+ if (uppers*1000/stripped > 750) /* .. and 75% or more of the visible chars are uppercase, kick user. */
Warning(g, GetDefaultText(msg_shouters), GetDefaultText(msg_no_shouting));
}
}
|