diff options
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/mime_encoding.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index 942358d11..17da31f30 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -477,30 +477,29 @@ rspamd_mime_charset_utf_enforce (gchar *in, gsize len) p = in; end = in + len; - while (p < end && len > 0 && (err_offset = rspamd_fast_utf8_validate (p, len) > 0)) { + while (p < end && len > 0 && (err_offset = rspamd_fast_utf8_validate (p, len)) > 0) { + err_offset --; /* As it returns it 1 indexed */ goffset cur_offset = err_offset; while (cur_offset < len) { goffset tmp = cur_offset; - U8_NEXT (in, cur_offset, len, uc); + U8_NEXT (p, cur_offset, len, uc); if (uc > 0) { /* Fill string between err_offset and tmp with `?` character */ - memset (in + err_offset, '?', - tmp - err_offset); + memset (p + err_offset - 1, '?', tmp - err_offset); break; } } if (uc < 0) { /* Fill till the end */ - memset (p + err_offset, '?', - len - err_offset); + memset (p + err_offset, '?', len - err_offset); break; } - p = in + cur_offset; + p += cur_offset; len = end - p; } } |