commit fe8028c: [Minor] Strip some bad characters from CTE headers

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Apr 8 12:56:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-04-08 13:55:09 +0100
URL: https://github.com/rspamd/rspamd/commit/fe8028c1083719f2597e015f16e1d24a4847244c (HEAD -> master)

[Minor] Strip some bad characters from CTE headers

---
 src/libmime/message.c     | 5 +++++
 src/libmime/mime_parser.c | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/libmime/message.c b/src/libmime/message.c
index 9bbd25d32..56f0a0a98 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -690,6 +690,11 @@ rspamd_message_process_plain_text_part (struct rspamd_task *task,
 		/* Check for ical */
 		rspamd_ftok_t cal_ct;
 
+		/*
+		 * TODO: If we want to process more than that, we need
+		 * to create some generic framework that accepts a part
+		 * and returns a processed data
+		 */
 		RSPAMD_FTOK_ASSIGN (&cal_ct, "calendar");
 
 		if (rspamd_ftok_casecmp (&cal_ct, &text_part->mime_part->ct->subtype) == 0) {
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index dc55efe20..6572f4e88 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -148,10 +148,13 @@ rspamd_mime_parser_init_lib (void)
 static enum rspamd_cte
 rspamd_mime_parse_cte (const gchar *in, gsize len)
 {
-	guint64 h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64,
-			in, len, 0xdeadbabe);
+	guint64 h;
 	enum rspamd_cte ret = RSPAMD_CTE_UNKNOWN;
 
+	in = rspamd_string_len_strip (in, &len, " \t;,.+-#!`~'");
+	h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64,
+			in, len, 0xdeadbabe);
+
 	switch (h) {
 	case 0xCEDAA7056B4753F7ULL: /* 7bit */
 		ret = RSPAMD_CTE_7BIT;


More information about the Commits mailing list