commit 2f3820f: [Fix] Workaround for empty charset in rfc2231 encoding
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Jul 26 11:56:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-07-26 12:49:37 +0100
URL: https://github.com/rspamd/rspamd/commit/2f3820f87e08b2a5ce1c67b59f1d5ef7ea22c99f (HEAD -> master)
[Fix] Workaround for empty charset in rfc2231 encoding
---
src/libmime/content_type.c | 19 +++++++++++++------
1 file 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, ¶m->value.len, &err);
More information about the Commits
mailing list