aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-07-27 16:57:32 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-07-27 16:57:32 +0100
commit6a1a93fffccd1344c87b33d7baacf9d25b5ba97b (patch)
treec85b02f48d78c03390eef08d352a9d400674be8d /src/libmime
parentdb3d0cb4b994558f63a28011a13a9e08d5f6d1d8 (diff)
downloadrspamd-6a1a93fffccd1344c87b33d7baacf9d25b5ba97b.tar.gz
rspamd-6a1a93fffccd1344c87b33d7baacf9d25b5ba97b.zip
[Fix] Detect empty text part as text, not HTML
Issue: #2367
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/message.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 6208f6424..76f63ed1a 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -675,16 +675,21 @@ rspamd_message_process_text_part (struct rspamd_task *task,
RSPAMD_FTOK_ASSIGN (&html_tok, "<!DOCTYPE html");
RSPAMD_FTOK_ASSIGN (&xhtml_tok, "<html");
- if (rspamd_lc_cmp (mime_part->parsed_data.begin, html_tok.begin,
- MIN (html_tok.len, mime_part->parsed_data.len)) == 0 ||
- rspamd_lc_cmp (mime_part->parsed_data.begin, xhtml_tok.begin,
- MIN (xhtml_tok.len, mime_part->parsed_data.len)) == 0) {
- msg_info_task ("found html part pretending to be text/plain part");
+ if (mime_part->parsed_data.len >= xhtml_tok.len &&
+ rspamd_lc_cmp (mime_part->parsed_data.begin, xhtml_tok.begin, xhtml_tok.len)) {
+ found_html = TRUE;
+ }
+ else if (mime_part->parsed_data.len >= html_tok.len &&
+ rspamd_lc_cmp (mime_part->parsed_data.begin, html_tok.begin, html_tok.len)) {
found_html = TRUE;
}
else {
found_txt = TRUE;
}
+
+ if (found_html) {
+ msg_info_task ("found html part pretending to be text/plain part");
+ }
}
}
else {