mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-07 13:43:12 +02:00
- badword::action::block should now be ok
This commit is contained in:
@@ -2052,3 +2052,4 @@ seen. gmtime warning still there
|
||||
AngryWolf
|
||||
- Made it so you can use a ~ as the first character of an ident with /chgident (#0000765)
|
||||
reported by AngryWolf
|
||||
- badword::action::block should now be ok
|
||||
|
||||
+25
-15
@@ -52,20 +52,30 @@ int hlength = strlen (haystack);
|
||||
}
|
||||
inline int fast_badword_match(ConfigItem_badword *badword, char *line)
|
||||
{
|
||||
char *temp;
|
||||
int ret;
|
||||
if (!(badword->type & (BADW_TYPE_FAST_R|BADW_TYPE_FAST_L)))
|
||||
return (our_strcasestr(line, badword->word) ? 0 : 1);
|
||||
/* This can be made faster, but for now I just want it to work */
|
||||
temp = MyMallocEx(strlen(badword->word)+3);
|
||||
if (badword->type & BADW_TYPE_FAST_L)
|
||||
strcat(temp, "*");
|
||||
strcat(temp, badword->word);
|
||||
if (badword->type & BADW_TYPE_FAST_R)
|
||||
strcat(temp, "*");
|
||||
ret = match(temp, line);
|
||||
free(temp);
|
||||
return ret;
|
||||
char *p;
|
||||
int ret, bwlen = strlen(badword->word);
|
||||
if ((badword->type & BADW_TYPE_FAST_L) && (badword->type & BADW_TYPE_FAST_R))
|
||||
return (our_strcasestr(line, badword->word) ? 1 : 0);
|
||||
|
||||
p = line;
|
||||
while((p = our_strcasestr(p, badword->word)))
|
||||
{
|
||||
if (!(badword->type & BADW_TYPE_FAST_L))
|
||||
{
|
||||
if ((p != line) && isalnum(*(p - 1))) /* aaBLA but no *BLA */
|
||||
goto next;
|
||||
}
|
||||
if (!(badword->type & BADW_TYPE_FAST_R))
|
||||
{
|
||||
if (isalnum(*(p + bwlen))) /* BLAaa but no BLA* */
|
||||
goto next;
|
||||
}
|
||||
/* Looks like it matched */
|
||||
return 1;
|
||||
next:
|
||||
p += bwlen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* fast_badword_replace:
|
||||
* a fast replace routine written by Syzop used for replacing badwords.
|
||||
@@ -199,7 +209,7 @@ char *stripbadwords(char *str, ConfigItem_badword *start_bw, int *blocked)
|
||||
{
|
||||
if (this_word->action == BADWORD_BLOCK)
|
||||
{
|
||||
if (!fast_badword_match(this_word, cleanstr))
|
||||
if (fast_badword_match(this_word, cleanstr))
|
||||
{
|
||||
*blocked = 1;
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user