diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-05 21:02:09 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-04-05 21:02:09 +0100 |
commit | 616f1e200a5e4a1c82879d44e939ca57c7a56445 (patch) | |
tree | 81cf4e7273fa2f8e37713200bbc9126f90726346 /src/libmime/mime_headers.c | |
parent | e6201536d6cec6f6014862e7237d4030cb8b1e8d (diff) | |
download | rspamd-616f1e200a5e4a1c82879d44e939ca57c7a56445.tar.gz rspamd-616f1e200a5e4a1c82879d44e939ca57c7a56445.zip |
[Fix] Fix rfc2047 tokenization
Diffstat (limited to 'src/libmime/mime_headers.c')
-rw-r--r-- | src/libmime/mime_headers.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index 5044fc013..b333fcdfe 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -641,7 +641,7 @@ gchar * rspamd_mime_header_encode (const gchar *in, gsize len) { const gchar *p = in, *end = in + len; - gchar *out, encode_buf[80]; + gchar *out, encode_buf[80 * sizeof (guint32)]; GString *res; gboolean need_encoding = FALSE; @@ -664,12 +664,14 @@ rspamd_mime_header_encode (const gchar *in, gsize len) gint r; const gchar *prev; /* Choose step: =?UTF-8?Q?<qp>?= should be less than 76 chars */ - const guint step = (76 - 12) / 3 + 1; + guint step = (76 - 12) / 3 + 1; ulen = g_utf8_strlen (in, len); res = g_string_sized_new (len * 2 + 1); pos = 0; prev = in; + /* Adjust chunk size for unicode average length */ + step *= 1.0 * ulen / (gdouble)len; while (pos < ulen) { p = g_utf8_offset_to_pointer (in, pos); |