From: Vsevolod Stakhov Date: Thu, 23 Feb 2017 16:20:50 +0000 (+0000) Subject: [Minor] Allow ascii messages with undetected charset X-Git-Tag: 1.5.0~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9874e51856f1732362e8f8c55f0033e793d790ce;p=rspamd.git [Minor] Allow ascii messages with undetected charset --- 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);