diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-07 11:38:05 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-07 11:49:17 +0000 |
commit | a87070a16587cd02f3c1d3f930186a0e957a098a (patch) | |
tree | e5cbf8d28cc058c38eceef0b525b010638c6df2d /src/libmime/mime_expressions.c | |
parent | 152f1af776e055b48c0b23754bb1ced6d803b97d (diff) | |
download | rspamd-a87070a16587cd02f3c1d3f930186a0e957a098a.tar.gz rspamd-a87070a16587cd02f3c1d3f930186a0e957a098a.zip |
[Fix] Fix parsing of cte in expressions
Diffstat (limited to 'src/libmime/mime_expressions.c')
-rw-r--r-- | src/libmime/mime_expressions.c | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index 8a5672459..71b8d4bdc 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -1252,11 +1252,10 @@ rspamd_compare_transfer_encoding (struct rspamd_task * task, GArray * args, void *unused) { - GPtrArray *headerlist; struct expression_argument *arg; guint i; - struct rspamd_mime_header *rh; - static const char *hname = "Content-Transfer-Encoding"; + struct rspamd_mime_part *part; + enum rspamd_cte cte; if (args == NULL) { msg_warn_task ("no parameters to function"); @@ -1269,39 +1268,16 @@ rspamd_compare_transfer_encoding (struct rspamd_task * task, return FALSE; } - headerlist = rspamd_message_get_header_array (task, hname, FALSE); + cte = rspamd_cte_from_string (arg->data); - if (headerlist) { - for (i = 0; i < headerlist->len; i ++) { - rh = g_ptr_array_index (headerlist, i); - - if (rh->decoded == NULL) { - continue; - } - - if (g_ascii_strcasecmp (rh->decoded, arg->data) == 0) { - return TRUE; - } - } + if (cte == RSPAMD_CTE_UNKNOWN) { + msg_warn_task ("unknown cte: %s", arg->data); + return FALSE; } - /* - * In fact, we need to check 'Content-Transfer-Encoding' for each part - * as gmime has 'strange' assumptions - */ - headerlist = rspamd_message_get_mime_header_array (task, - arg->data, - FALSE); - - if (headerlist) { - for (i = 0; i < headerlist->len; i ++) { - rh = g_ptr_array_index (headerlist, i); - - if (rh->decoded == NULL) { - continue; - } - - if (g_ascii_strcasecmp (rh->decoded, arg->data) == 0) { + PTR_ARRAY_FOREACH (task->parts, i, part) { + if (IS_CT_TEXT (part->ct)) { + if (part->cte == cte) { return TRUE; } } |