1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-08 18:13:12 +02:00
This commit is contained in:
codemastr
2003-04-13 17:13:01 +00:00
parent 7000658c42
commit a38c76dd44
2 changed files with 29 additions and 29 deletions
+22 -13
View File
@@ -50,7 +50,23 @@ int hlength = strlen (haystack);
}
return NULL; /* not found */
}
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;
}
/* fast_badword_replace:
* a fast replace routine written by Syzop used for replacing badwords.
* searches in line for huntw and replaces it with replacew,
@@ -183,18 +199,11 @@ char *stripbadwords(char *str, ConfigItem_badword *start_bw, int *blocked)
{
if (this_word->action == BADWORD_BLOCK)
{
if (!(this_word->type & (BADW_TYPE_FAST_R|BADW_TYPE_FAST_L)))
if (our_strcasestr(cleanstr, this_word->word))
{
*blocked = 1;
return NULL;
}
else
if (!match(this_word->word, cleanstr))
{
*blocked = 1;
return NULL;
}
if (!fast_badword_match(this_word, cleanstr))
{
*blocked = 1;
return NULL;
}
}
else
{
+7 -16
View File
@@ -4286,22 +4286,13 @@ int _conf_badword(ConfigFile *conf, ConfigEntry *ce)
} else {
char *tmpw;
ca->type = BADW_TYPE_FAST;
if (ca->action == BADWORD_BLOCK)
{
/* If it is set to block, we'll just use a match() or an
* our_strcasestr as necessary
*/
ircstrdup(ca->word, cep->ce_vardata);
}
else
{
ca->word = tmpw = MyMalloc(strlen(cep->ce_vardata) - ast_l - ast_r + 1);
/* Copy except for asterisks */
for (tmp = cep->ce_vardata; *tmp; tmp++)
if (*tmp != '*')
*tmpw++ = *tmp;
*tmpw = '\0';
}
ircstrdup(ca->word, cep->ce_vardata);
ca->word = tmpw = MyMalloc(strlen(cep->ce_vardata) - ast_l - ast_r + 1);
/* Copy except for asterisks */
for (tmp = cep->ce_vardata; *tmp; tmp++)
if (*tmp != '*')
*tmpw++ = *tmp;
*tmpw = '\0';
if (ast_l)
ca->type |= BADW_TYPE_FAST_L;
if (ast_r)