aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/expressions.c2
-rw-r--r--src/message.c70
-rw-r--r--src/plugins/regexp.c3
3 files changed, 59 insertions, 16 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 6519879c5..df6f0271f 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -876,6 +876,8 @@ rspamd_content_type_has_param (struct worker_task *task, GList *args)
ct = g_mime_object_get_content_type (part);
g_object_unref (part);
+ msg_debug ("rspamd_content_type_has_param: checking %s param", param_name);
+
if ((param_data = g_mime_content_type_get_parameter (ct, param_name)) == NULL) {
return FALSE;
}
diff --git a/src/message.c b/src/message.c
index 4d6ba95d1..0dd1ff096 100644
--- a/src/message.c
+++ b/src/message.c
@@ -641,36 +641,29 @@ enum {
HEADER_UNKNOWN
};
-static GList *
-local_message_get_header(memory_pool_t *pool, GMimeMessage *message, const char *field)
-{
- GList * gret = NULL;
#ifndef GMIME24
- struct raw_header *h;
-
- if (field == NULL) {
- return NULL;
- }
- h = GMIME_OBJECT(message)->headers->headers;
+static void
+header_iterate (memory_pool_t *pool, struct raw_header *h, GList *ret, const char *field)
+{
while (h) {
if (h->value && !g_strncasecmp (field, h->name, strlen (field))) {
if (pool != NULL) {
- gret = g_list_prepend (gret, memory_pool_strdup (pool, h->value));
+ ret = g_list_prepend (ret, memory_pool_strdup (pool, h->value));
}
else {
- gret = g_list_prepend (gret, g_strdup (h->value));
+ ret = g_list_prepend (ret, g_strdup (h->value));
}
}
h = h->next;
}
- return gret;
+}
#else
- GMimeHeaderList *ls;
+static void
+header_iterate (memory_pool_t *pool, GMimeHeaderList *ls, GList *ret, const char field)
+{
GMimeHeaderIter *iter;
const char *name;
- ls = GMIME_OBJECT(message)->headers;
-
if (g_mime_header_list_get_iter (ls, iter)) {
while (g_mime_header_iter_is_valid (iter)) {
name = g_mime_header_iter_get_name (iter);
@@ -688,6 +681,50 @@ local_message_get_header(memory_pool_t *pool, GMimeMessage *message, const char
}
}
}
+}
+#endif
+
+static GList *
+local_message_get_header(memory_pool_t *pool, GMimeMessage *message, const char *field)
+{
+ GList * gret = NULL;
+ GMimeObject *part;
+#ifndef GMIME24
+ struct raw_header *h;
+
+ if (field == NULL) {
+ return NULL;
+ }
+
+ h = GMIME_OBJECT(message)->headers->headers;
+ header_iterate (pool, h, gret, field);
+
+ if (gret == NULL) {
+ /* Try to iterate with mime part headers */
+ part = g_mime_message_get_mime_part (message);
+ if (part) {
+ h = part->headers->headers;
+ header_iterate (pool, h, gret, field);
+ g_object_unref (part);
+ }
+ }
+
+ return gret;
+#else
+ GMimeHeaderList *ls;
+
+ ls = GMIME_OBJECT(message)->headers;
+ header_iterate (pool, ls, gret, field);
+ if (gret == NULL) {
+ /* Try to iterate with mime part headers */
+ part = g_mime_message_get_mime_part (message);
+ if (part) {
+ ls = part->headers;
+ header_iterate (pool, ls, gret, field);
+ g_object_unref (part);
+ }
+ }
+
return gret;
#endif
@@ -710,6 +747,7 @@ local_mime_message_set_date_from_string (GMimeMessage *message, const gchar *str
g_mime_message_set_date (message, date, offset);
}
+
#ifdef GMIME24
#define ADD_RECIPIENT_TEMPLATE(type,def) \
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index f057b29c2..27278b3c8 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -304,16 +304,19 @@ optimize_regexp_expression (struct expression **e, GQueue *stack, gboolean res)
if (it->type == EXPR_OPERATION) {
/* If this operation is just ! just inverse res and check for further operators */
if (it->content.operation == '!' && is_nearest) {
+ msg_debug ("optimize_regexp_expression: found '!' operator, inversing result");
res = !res;
it = it->next;
*e = it;
continue;
}
else if (it->content.operation == '&' && res == FALSE) {
+ msg_debug ("optimize_regexp_expression: found '&' and previous expression is false");
*e = it;
ret = TRUE;
}
else if (it->content.operation == '|' && res == TRUE) {
+ msg_debug ("optimize_regexp_expression: found '|' and previous expression is true");
*e = it;
ret = TRUE;
}