From b152b39df64263ceda213eb61ed6e744e5092a03 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 4 May 2018 16:03:51 +0100 Subject: [PATCH] [Fix] Fix raw_mime regexp on HTML part with no text content Issue: #2218 Closes: #2218 --- src/libserver/re_cache.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 98fe0a395..c47db5761 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -880,26 +880,34 @@ rspamd_re_cache_exec_re (struct rspamd_task *task, for (i = 0; i < task->text_parts->len; i++) { part = g_ptr_array_index (task->text_parts, i); - /* Skip empty parts */ - if (IS_PART_EMPTY (part)) { - lenvec[i] = 0; - scvec[i] = (guchar *) ""; - continue; - } - - /* Check raw flags */ - if (!IS_PART_UTF (part)) { - raw = TRUE; - } /* Select data for regexp */ if (re_class->type == RSPAMD_RE_RAWMIME) { - in = part->raw.begin; - len = part->raw.len; + if (part->raw.len == 0) { + len = 0; + in = ""; + } + else { + in = part->raw.begin; + len = part->raw.len; + } + raw = TRUE; } else { - in = part->content->data; - len = part->content->len; + /* Skip empty parts */ + if (IS_PART_EMPTY (part)) { + len = 0; + in = ""; + } + else { + /* Check raw flags */ + if (!IS_PART_UTF (part)) { + raw = TRUE; + } + + in = part->content->data; + len = part->content->len; + } } scvec[i] = (guchar *) in; -- 2.39.5