commit ad5850d: [Minor] Lowercase content-type as specified in rfc2045

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jun 25 10:14:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-06-25 11:11:52 +0100
URL: https://github.com/rspamd/rspamd/commit/ad5850db20e6f66a1d9a7314d227f9eec296e9f0

[Minor] Lowercase content-type as specified in rfc2045

---
 src/libmime/content_type.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c
index d092c0dc4..11fa8cd65 100644
--- a/src/libmime/content_type.c
+++ b/src/libmime/content_type.c
@@ -597,8 +597,26 @@ rspamd_content_type_parser (gchar *in, gsize len, rspamd_mempool_t *pool)
 	}
 
 	if (val.type.len > 0) {
+		gchar *tmp;
+
 		res = rspamd_mempool_alloc (pool, sizeof (val));
 		memcpy (res, &val, sizeof (val));
+
+		/*
+		 * Lowercase type and subtype as they are specified as case insensitive
+		 * in rfc2045 section 5.1
+		 */
+		tmp = rspamd_mempool_alloc (pool, val.type.len);
+		memcpy (tmp, val.type.begin, val.type.len);
+		rspamd_str_lc (tmp, val.type.len);
+		res->type.begin = tmp;
+
+		if (val.subtype.len > 0) {
+			tmp = rspamd_mempool_alloc (pool, val.subtype.len);
+			memcpy (tmp, val.subtype.begin, val.subtype.len);
+			rspamd_str_lc (tmp, val.subtype.len);
+			res->subtype.begin = tmp;
+		}
 	}
 
 	return res;


More information about the Commits mailing list