Support single quotes in spamfilter::rule, for like xyz('bla/bla')

This commit is contained in:
Bram Matthys 2023-07-16 09:29:18 +02:00
parent d5e8e8f324
commit 36fc839022
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98

View file

@ -444,7 +444,7 @@ static int crule_gettoken(crule_token *next_tokp, const char **ruleptr)
break;
default:
if ((isalnum(*(--(*ruleptr)))) || (**ruleptr == '*') ||
(**ruleptr == '?') || (**ruleptr == '.') || (**ruleptr == '-') || (**ruleptr == '_'))
(**ruleptr == '?') || (**ruleptr == '.') || (**ruleptr == '-') || (**ruleptr == '_') || (**ruleptr == '\''))
*next_tokp = CR_WORD;
else
return CR_UNKNWTOK;
@ -462,18 +462,30 @@ static int crule_gettoken(crule_token *next_tokp, const char **ruleptr)
static void crule_getword(char *word, int *wordlenp, size_t maxlen, const char **ruleptr)
{
char *word_ptr;
char quoted = 0;
word_ptr = word;
if (**ruleptr == '\'')
{
*(*ruleptr)++;
quoted = 1;
}
while ((size_t)(word_ptr - word) < maxlen
&& (isalnum(**ruleptr)
|| **ruleptr == '*' || **ruleptr == '?'
|| **ruleptr == '.' || **ruleptr == '-'
|| **ruleptr == '_'))
|| **ruleptr == '_' || (quoted && (**ruleptr != '\''))))
{
*word_ptr++ = *(*ruleptr)++;
}
*word_ptr = '\0';
*wordlenp = word_ptr - word;
/* Eat the remaining ' quote, if needed... */
if (quoted && (**ruleptr == '\''))
*(*ruleptr)++;;
}
/** Parse an entire rule.