From ad5850db20e6f66a1d9a7314d227f9eec296e9f0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 25 Jun 2019 11:11:52 +0100 Subject: [PATCH] [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; -- 2.39.5