summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-26 12:49:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-26 12:49:37 +0100
commit2f3820f87e08b2a5ce1c67b59f1d5ef7ea22c99f (patch)
tree35ca50f062c034e0e5ab5f14f3f4a1ea5c4720dc /src
parent02d842a709915be441146d9076e4e6b03f45deac (diff)
downloadrspamd-2f3820f87e08b2a5ce1c67b59f1d5ef7ea22c99f.tar.gz
rspamd-2f3820f87e08b2a5ce1c67b59f1d5ef7ea22c99f.zip
[Fix] Workaround for empty charset in rfc2231 encoding
Diffstat (limited to 'src')
-rw-r--r--src/libmime/content_type.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c
index 11fa8cd65..ea48c0373 100644
--- a/src/libmime/content_type.c
+++ b/src/libmime/content_type.c
@@ -48,12 +48,8 @@ rspamd_rfc2231_decode (rspamd_mempool_t *pool,
ctok.begin = value_start;
ctok.len = quote_pos - value_start;
- charset = rspamd_mime_detect_charset (&ctok, pool);
-
- if (charset == NULL) {
- msg_warn_pool ("cannot convert parameter from charset %T", &ctok);
-
- return FALSE;
+ if (ctok.len > 0) {
+ charset = rspamd_mime_detect_charset (&ctok, pool);
}
/* Now, we can check for either next quote sign or, eh, ignore that */
@@ -71,6 +67,17 @@ rspamd_rfc2231_decode (rspamd_mempool_t *pool,
value_end - value_start);
GError *err = NULL;
+ if (charset == NULL) {
+ /* Try heuristic */
+ charset = rspamd_mime_charset_find_by_content (value_start, r);
+ }
+
+ if (charset == NULL) {
+ msg_warn_pool ("cannot convert parameter from charset %T", &ctok);
+
+ return FALSE;
+ }
+
param->value.begin = rspamd_mime_text_to_utf8 (pool,
value_start, r,
charset, &param->value.len, &err);