aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_headers.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-20 12:40:28 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-20 13:00:11 +0000
commitc305ef1157ea4c578a783cc66ebcea66efdc851a (patch)
treed432fbc2636bd4f2a10575b6029591618e75b179 /src/libmime/mime_headers.c
parent8a4524a191c7d96d2a7b69e7a388493aecf145f8 (diff)
downloadrspamd-c305ef1157ea4c578a783cc66ebcea66efdc851a.tar.gz
rspamd-c305ef1157ea4c578a783cc66ebcea66efdc851a.zip
[Fix] Fix issues with quoted-printable encoding
Diffstat (limited to 'src/libmime/mime_headers.c')
-rw-r--r--src/libmime/mime_headers.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 9503862ce..27c427ae5 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -352,6 +352,7 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
rspamd_ftok_t cur_charset = {0, NULL}, old_charset = {0, NULL};
gint encoding;
gssize r;
+ guint qmarks = 0;
enum {
parse_normal = 0,
got_eqsign,
@@ -384,6 +385,7 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
case got_eqsign:
if (*p == '?') {
state = got_encoded_start;
+ qmarks = 0;
}
else {
g_string_append_len (out, c, 2);
@@ -394,13 +396,17 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
case got_encoded_start:
if (*p == '?') {
state = got_more_qmark;
+ qmarks ++;
}
p ++;
break;
case got_more_qmark:
if (*p == '=') {
+ if (qmarks < 3) {
+ state = got_encoded_start;
+ }
/* Finished encoded boundary */
- if (rspamd_rfc2047_parser (c, p - c + 1, &encoding,
+ else if (rspamd_rfc2047_parser (c, p - c + 1, &encoding,
&cur_charset.begin, &cur_charset.len,
&tok_start, &tok_len)) {
/* We have a token, so we can decode it from `encoding` */
@@ -409,6 +415,8 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
token, decoded,
&old_charset, &cur_charset);
}
+
+ qmarks = 0;
pos = token->len;
g_byte_array_set_size (token, pos + tok_len);
@@ -434,6 +442,7 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
token->len -= tok_len;
}
}
+
c = p + 1;
state = skip_spaces;
}