From: Vsevolod Stakhov Date: Tue, 25 Jun 2019 10:11:52 +0000 (+0100) Subject: [Minor] Lowercase content-type as specified in rfc2045 X-Git-Tag: 2.0~736 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad5850db20e6f66a1d9a7314d227f9eec296e9f0;p=thirdparty%2Frspamd.git [Minor] Lowercase content-type as specified in rfc2045 --- diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c index d092c0dc46..11fa8cd653 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;