summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-07-29 19:55:50 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-07-29 19:55:50 +0400
commitc01a88e64c16cdd14be32d1fe964f9ba8fb44f5e (patch)
tree47361065203b531d2467d51a0492e8f8c1276964 /src
parent3af9f6d59d72d65987ffd0b19257a3b1f9aaf29b (diff)
downloadrspamd-c01a88e64c16cdd14be32d1fe964f9ba8fb44f5e.tar.gz
rspamd-c01a88e64c16cdd14be32d1fe964f9ba8fb44f5e.zip
* Add error handling for regexps0.3.1
Diffstat (limited to 'src')
-rw-r--r--src/plugins/regexp.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 85b9e6594..81c267a4a 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -560,9 +560,9 @@ tree_url_callback (gpointer key, gpointer value, void *data)
{
struct url_regexp_param *param = data;
struct uri *url = value;
+ GError *err = NULL;
-
- if (g_regex_match (param->regexp, struri (url), 0, NULL) == TRUE) {
+ if (g_regex_match_full (param->regexp, struri (url), -1, 0, 0, NULL, &err) == TRUE) {
if (G_UNLIKELY (param->re->is_test)) {
msg_info ("process test regexp %s for url %s returned TRUE", struri (url));
}
@@ -573,6 +573,9 @@ tree_url_callback (gpointer key, gpointer value, void *data)
else if (G_UNLIKELY (param->re->is_test)) {
msg_info ("process test regexp %s for url %s returned FALSE", struri (url));
}
+ if (err != NULL) {
+ msg_info ("error occured while processing regexp \"%s\": %s", param->re->regexp_text, err->message);
+ }
return FALSE;
}
@@ -584,6 +587,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
struct mime_text_part *part;
GList *cur, *headerlist;
GRegex *regexp;
+ GError *err = NULL;
struct url_regexp_param callback_param = {
.task = task,
.regexp = re->regexp,
@@ -652,7 +656,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
while (cur) {
debug_task ("found header \"%s\" with value \"%s\"", re->header, (const char *)cur->data);
- if (cur->data && g_regex_match (re->regexp, cur->data, 0, NULL) == TRUE) {
+ if (cur->data && g_regex_match_full (re->regexp, cur->data, -1, 0, 0, NULL, &err) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const char *)cur->data);
}
@@ -662,6 +666,9 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
else if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const char *)cur->data);
}
+ if (err != NULL) {
+ msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
+ }
cur = g_list_next (cur);
}
task_cache_add (task, re, 0);
@@ -685,7 +692,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
regexp = re->regexp;
}
- if (g_regex_match_full (regexp, part->orig->data, part->orig->len, 0, 0, NULL, NULL) == TRUE) {
+ if (g_regex_match_full (regexp, part->orig->data, part->orig->len, 0, 0, NULL, &err) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for mime part returned TRUE", re->regexp_text);
}
@@ -695,6 +702,9 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
else if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (int)part->orig->len);
}
+ if (err != NULL) {
+ msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
+ }
cur = g_list_next (cur);
}
task_cache_add (task, re, 0);
@@ -702,7 +712,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
case REGEXP_MESSAGE:
debug_task ("checking message regexp: %s", re->regexp_text);
- if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, NULL) == TRUE) {
+ if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, &err) == TRUE) {
if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (int)task->msg->len);
}
@@ -712,6 +722,9 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
else if (G_UNLIKELY (re->is_test)) {
msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (int)task->msg->len);
}
+ if (err != NULL) {
+ msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
+ }
task_cache_add (task, re, 0);
return 0;
case REGEXP_URL:
@@ -783,7 +796,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
*c = '\0';
debug_task ("found raw header \"%s\" with value \"%s\"", re->header, headerv);
- if (g_regex_match (re->raw_regexp, headerv, 0, NULL) == TRUE) {
+ if (g_regex_match_full (re->raw_regexp, headerv, -1, 0, 0, NULL, &err) == TRUE) {
if (re->is_test) {
msg_info ("process test regexp %s for raw header %s with value '%s' returned TRUE", re->regexp_text, re->header, headerv);
}
@@ -794,6 +807,9 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
else if (re->is_test) {
msg_info ("process test regexp %s for raw header %s with value '%s' returned FALSE", re->regexp_text, re->header, headerv);
}
+ if (err != NULL) {
+ msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
+ }
*c = t;
task_cache_add (task, re, 0);
return 0;