From 9874e51856f1732362e8f8c55f0033e793d790ce Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 23 Feb 2017 16:20:50 +0000 Subject: [PATCH] [Minor] Allow ascii messages with undetected charset --- src/libmime/mime_encoding.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index 59df89ece..a9ddb42fa 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -392,6 +392,17 @@ rspamd_mime_charset_find_by_content (gchar *in, gsize inlen) g_assert (csd != NULL); } + /* If text is ascii, then we can treat it as utf8 data */ + for (i = 0; i < inlen; i++) { + if ((((guchar)in[i]) & 0x80) != 0) { + goto detect; + } + } + + return UTF8_CHARSET; + +detect: + ucsdet_setText (csd, in, inlen, &uc_err); csm = ucsdet_detectAll(csd, &matches, &uc_err); -- 2.39.5