aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_parser.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-24 10:58:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-24 10:58:17 +0000
commitb9bce692b339291c3884aa032c649c58ea9317a6 (patch)
treebe9cf805b46493db565b581b1278656b0b9c4969 /src/libmime/mime_parser.c
parent61cd3e34e389d562aa4d8ce6d93c0d97aeb304e6 (diff)
downloadrspamd-b9bce692b339291c3884aa032c649c58ea9317a6.tar.gz
rspamd-b9bce692b339291c3884aa032c649c58ea9317a6.zip
[Fix] Fix parsing of messages with no content type
Issue: #1283 Reported by: @moisseev
Diffstat (limited to 'src/libmime/mime_parser.c')
-rw-r--r--src/libmime/mime_parser.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index a78c9d072..c501b99ec 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -861,31 +861,32 @@ rspamd_mime_parse_message (struct rspamd_task *task,
npart->parent_part = part;
if (hdrs == NULL) {
- g_set_error (err, RSPAMD_MIME_QUARK, EINVAL,
- "Content type header is absent");
-
- return FALSE;
+ sel = NULL;
}
+ else {
- for (i = 0; i < hdrs->len; i ++) {
- hdr = g_ptr_array_index (hdrs, i);
- ct = rspamd_content_type_parse (hdr->value, strlen (hdr->value),
- task->task_pool);
+ for (i = 0; i < hdrs->len; i ++) {
+ hdr = g_ptr_array_index (hdrs, i);
+ ct = rspamd_content_type_parse (hdr->value, strlen (hdr->value),
+ task->task_pool);
- /* Here we prefer multipart content-type or any content-type */
- if (ct) {
- if (sel == NULL) {
- sel = ct;
- }
- else if (ct->flags & RSPAMD_CONTENT_TYPE_MULTIPART) {
- sel = ct;
+ /* Here we prefer multipart content-type or any content-type */
+ if (ct) {
+ if (sel == NULL) {
+ sel = ct;
+ }
+ else if (ct->flags & RSPAMD_CONTENT_TYPE_MULTIPART) {
+ sel = ct;
+ }
}
}
}
if (sel == NULL) {
/* For messages we automatically assume plaintext */
+ msg_info_task ("cannot find content-type for a message, assume text/plain");
sel = rspamd_mempool_alloc0 (task->task_pool, sizeof (*sel));
+ sel->flags = RSPAMD_CONTENT_TYPE_TEXT|RSPAMD_CONTENT_TYPE_BROKEN;
RSPAMD_FTOK_ASSIGN (&sel->type, "text");
RSPAMD_FTOK_ASSIGN (&sel->subtype, "plain");
}