break;
case field_xspamstatus:
- if (!IsEmptyStr(msg->cm_fields[eMesageText])) {
- if ((ptr=strstr(msg->cm_fields[eMesageText],"X-Spam-Status"))!=NULL) {
+ if (!IsEmptyStr(msg->cm_fields[eMessageText])) {
+ if ((ptr=strstr(msg->cm_fields[eMessageText],"X-Spam-Status"))!=NULL) {
len=0;
ptr1=ptr;
while (*ptr1 && (*ptr1!='\r') && (*ptr1!='\n')) {
int substring_match = 0;
int regex_match = 0;
int exact_match = 0;
+ int rc = 0;
regex_t regex;
- if (regcomp(®ex, ii->rules[i].compared_value, (REG_EXTENDED | REG_ICASE | REG_NOSUB | REG_NEWLINE))) {
- syslog(LOG_ERR, "inboxrules: regcomp: %m");
+
+ rc = regcomp(®ex, ii->rules[i].compared_value, (REG_EXTENDED | REG_ICASE | REG_NOSUB | REG_NEWLINE));
+ if (rc) {
+ syslog(LOG_ERR, "inboxrules: regcomp: error %d trying to compile \"%s\"", rc, ii->rules[i].compared_value);
}
if (compare_compound) { // comparing a compound field such as name+address
(bmstrcasestr(compare_me, ii->rules[i].compared_value) ? 1 : 0)
+ (bmstrcasestr(sep, ii->rules[i].compared_value) ? 1 : 0)
;
- regex_match =
+ if (!rc) regex_match =
(regexec(®ex, compare_me, 0, 0, 0) ? 0 : 1)
+ (regexec(®ex, sep, 0, 0, 0) ? 0 : 1)
;
else { // comparing a single field only
exact_match = (strcasecmp(compare_me, ii->rules[i].compared_value) ? 0 : 1);
substring_match = (bmstrcasestr(compare_me, ii->rules[i].compared_value) ? 1 : 0);
- regex_match = (regexec(®ex, compare_me, 0, 0, 0) ? 1 : 0);
+ if (!rc) regex_match = (regexec(®ex, compare_me, 0, 0, 0) ? 0 : 1);
}
+
regfree(®ex);
- syslog(LOG_DEBUG, "substring match: %d", substring_match);
- syslog(LOG_DEBUG, " regex match: %d", regex_match);
- syslog(LOG_DEBUG, " exact match: %d", exact_match);
+ syslog(LOG_DEBUG, "inboxrules: substring match: %d", substring_match);
+ syslog(LOG_DEBUG, "inboxrules: regex match: %d", regex_match);
+ syslog(LOG_DEBUG, "inboxrules: exact match: %d", exact_match);
switch(ii->rules[i].field_compare_op) {
case fcomp_contains:
rule_activated = substring_match;
return; // config msgnum is set but that message does not exist
}
- ii = deserialize_inbox_rules(msg->cm_fields[eMesageText]);
+ ii = deserialize_inbox_rules(msg->cm_fields[eMessageText]);
CM_Free(msg);
if (ii == NULL) {
struct CtdlMessage *msg = CtdlFetchMessage(CC->user.msgnum_inboxrules, 1);
if (msg != NULL) {
- if (!CM_IsEmpty(msg, eMesageText)) {
+ if (!CM_IsEmpty(msg, eMessageText)) {
char *token;
- char *rest = msg->cm_fields[eMesageText];
+ char *rest = msg->cm_fields[eMessageText];
while ((token = strtok_r(rest, "\n", &rest))) {
// for backwards compatibility, "# WEBCIT_RULE" is an alias for "rule"