From 01727d5d8b5432c3de595bb1af961cdd3559ebcd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 18 Dec 2016 18:21:15 +0000 Subject: [PATCH] [Fix] Fix processing of parts with no valid content type --- src/libmime/mime_parser.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 6dec581bf..b690f3aa5 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -437,10 +437,9 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task, } if (sel == NULL) { - /* TODO: assume part as octet-stream */ - g_set_error (err, RSPAMD_MIME_QUARK, EINVAL, "no content type"); - g_assert (0); - return FALSE; + sel = rspamd_mempool_alloc0 (task->task_pool, sizeof (*sel)); + RSPAMD_FTOK_ASSIGN (&sel->type, "application"); + RSPAMD_FTOK_ASSIGN (&sel->subtype, "octet-stream"); } npart->ct = sel; @@ -777,7 +776,7 @@ rspamd_mime_parse_message (struct rspamd_task *task, /* * Exim somehow uses mailbox format for messages being scanned: - * From xxx@xxx.com Fri May 13 19:08:48 2016 + * From x@x.com Fri May 13 19:08:48 2016 * * So we check if a task has non-http format then we check for such a line * at the beginning to avoid errors @@ -886,11 +885,10 @@ rspamd_mime_parse_message (struct rspamd_task *task, } if (sel == NULL) { - g_set_error (err, RSPAMD_MIME_QUARK, EINVAL, - "Content type header cannot be parsed"); - - /* TODO: assume it raw */ - return FALSE; + /* For messages we automatically assume plaintext */ + sel = rspamd_mempool_alloc0 (task->task_pool, sizeof (*sel)); + RSPAMD_FTOK_ASSIGN (&sel->type, "text"); + RSPAMD_FTOK_ASSIGN (&sel->subtype, "plain"); } npart->ct = sel; -- 2.39.5