aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_headers.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-29 15:45:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-29 15:45:34 +0000
commitd664f2fd52d6050460c9ca0ddebe8ef990fa0fb5 (patch)
tree5f11a8244bfb42826fcf4961642b04610005c39e /src/libmime/mime_headers.c
parent36c874383c4c56fb10c737a3f5932abc173080e2 (diff)
downloadrspamd-d664f2fd52d6050460c9ca0ddebe8ef990fa0fb5.tar.gz
rspamd-d664f2fd52d6050460c9ca0ddebe8ef990fa0fb5.zip
[Feature] Allow to get task flags in C expressions
Diffstat (limited to 'src/libmime/mime_headers.c')
-rw-r--r--src/libmime/mime_headers.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index b782db010..12661f0ea 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -348,8 +348,15 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
}
nh->value = tmp;
+
+ gboolean broken_utf = FALSE;
+
nh->decoded = rspamd_mime_header_decode (task->task_pool,
- nh->value, strlen (tmp));
+ nh->value, strlen (tmp), &broken_utf);
+
+ if (broken_utf) {
+ task->flags |= RSPAMD_TASK_FLAG_BAD_UNICODE;
+ }
if (nh->decoded == NULL) {
nh->decoded = "";
@@ -531,7 +538,7 @@ rspamd_mime_header_sanity_check (GString *str)
gchar *
rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
- gsize inlen)
+ gsize inlen, gboolean *invalid_utf)
{
GString *out;
const guchar *c, *p, *end;
@@ -583,6 +590,10 @@ rspamd_mime_header_decode (rspamd_mempool_t *pool, const gchar *in,
off = 0;
U8_APPEND_UNSAFE (out->str + out->len - 3,
off, 0xfffd);
+
+ if (invalid_utf) {
+ *invalid_utf = TRUE;
+ }
}
else {
c = p;