diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-23 12:08:46 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-23 12:08:46 +0000 |
commit | 1762eb9af61997d9acc3017e2e0fc6153b09acc2 (patch) | |
tree | f3ee7bc84345d2ebfb58dc3da9d8cc4c25aacc60 /src/libmime | |
parent | f4eccbbe6daaa1ca13bf765c92fb0c4b64c5f068 (diff) | |
download | rspamd-1762eb9af61997d9acc3017e2e0fc6153b09acc2.tar.gz rspamd-1762eb9af61997d9acc3017e2e0fc6153b09acc2.zip |
[Minor] Use a more sane replacement character
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/mime_encoding.c | 19 |
1 files changed, 15 insertions, 4 deletions
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; } |