aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/message.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-27 15:20:55 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-27 15:20:55 +0000
commit6f0693ceaebf44f80127e041bd4fbff48045c93c (patch)
tree97ca1aa560e2ae621a803711b665968ea2db4cce /src/libmime/message.c
parent89849bda3097cf3b561e81b7ae10ca65509175ea (diff)
downloadrspamd-6f0693ceaebf44f80127e041bd4fbff48045c93c.tar.gz
rspamd-6f0693ceaebf44f80127e041bd4fbff48045c93c.zip
[Minor] Add extra heuristic for text parts
Diffstat (limited to 'src/libmime/message.c')
-rw-r--r--src/libmime/message.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 46f528ba7..35ea5bb25 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -731,7 +731,36 @@ rspamd_message_process_text_part_maybe (struct rspamd_task *task,
found_html = TRUE;
}
else {
- found_txt = TRUE;
+ /* We need to be extra careful with some stupid things here */
+
+ html_tok.begin = "plain";
+ html_tok.len = 5;
+
+ if (rspamd_ftok_cmp (&mime_part->ct->subtype, &html_tok) == 0) {
+ found_txt = TRUE;
+ }
+ else {
+ if (mime_part->cd && mime_part->cd->filename.len > 4) {
+ const gchar *pos = mime_part->cd->filename.begin +
+ mime_part->cd->filename.len -
+ sizeof (".txt") + 1;
+ if (rspamd_lc_cmp (pos, ".txt", sizeof ("txt") - 1) == 0) {
+ found_txt = TRUE;
+ }
+ else {
+ msg_info_task ("found mime part with incorrect content-type: %T/%T, "
+ "filename: %T",
+ &mime_part->ct->type,
+ &mime_part->ct->subtype,
+ &mime_part->cd->filename);
+ mime_part->ct->flags |= RSPAMD_CONTENT_TYPE_BROKEN;
+ }
+ }
+ else {
+ /* For something like Content-Type: text */
+ found_txt = TRUE;
+ }
+ }
}
if (found_html) {