From: Vsevolod Stakhov Date: Mon, 23 Jan 2017 12:08:46 +0000 (+0000) Subject: [Minor] Use a more sane replacement character X-Git-Tag: 1.5.0~281 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1762eb9af61997d9acc3017e2e0fc6153b09acc2;p=rspamd.git [Minor] Use a more sane replacement character --- diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index dae93c89c..834455ea9 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -252,12 +252,23 @@ rspamd_mime_to_utf8_byte_array (GByteArray *in, break; case EILSEQ: case EINVAL: - /* Ignore bad characters */ - if (remain > 0 && inremain > 0) { - *d++ = '?'; + /* Replace bad characters with U+FFFD */ + if (inremain > 0) { + if (remain < 3) { + pos = outlen; + outlen += inremain * 4; + remain += inremain * 4; + /* May cause reallocate, so store previous len in pos */ + g_byte_array_set_size (out, outlen); + d = out->data + pos; + } + + *d++ = 0xEF; + *d++ = 0xBF; + *d++ = 0xBD; s++; inremain --; - remain --; + remain -= 3; } break; }