aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_headers.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-03 18:00:01 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-03 18:00:01 +0100
commit58e6cb1a4fce75ef521233bd734a7706b2f5e26f (patch)
treee4719206bd4ec1743f1cede24a4f29572231cf99 /src/libmime/mime_headers.c
parente1a378c031958b5ee10abd74e11683984a762c25 (diff)
downloadrspamd-58e6cb1a4fce75ef521233bd734a7706b2f5e26f.tar.gz
rspamd-58e6cb1a4fce75ef521233bd734a7706b2f5e26f.zip
[Feature] Store headers order
Diffstat (limited to 'src/libmime/mime_headers.c')
-rw-r--r--src/libmime/mime_headers.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 2ea4c0dcb..5044fc013 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -121,7 +121,8 @@ rspamd_mime_header_check_special (struct rspamd_task *task,
static void
rspamd_mime_header_add (struct rspamd_task *task,
- GHashTable *target, struct rspamd_mime_header *rh,
+ GHashTable *target, GQueue *order,
+ struct rspamd_mime_header *rh,
gboolean check_special)
{
GPtrArray *ar;
@@ -137,6 +138,8 @@ rspamd_mime_header_add (struct rspamd_task *task,
msg_debug_task ("add new raw header %s: %s", rh->name, rh->value);
}
+ g_queue_push_tail (order, rh);
+
if (check_special) {
rspamd_mime_header_check_special (task, rh);
}
@@ -145,7 +148,9 @@ rspamd_mime_header_add (struct rspamd_task *task,
/* Convert raw headers to a list of struct raw_header * */
void
rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
- const gchar *in, gsize len, gboolean check_newlines)
+ GQueue *order,
+ const gchar *in, gsize len,
+ gboolean check_newlines)
{
struct rspamd_mime_header *nh = NULL;
const gchar *p, *c, *end;
@@ -153,7 +158,7 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
gint state = 0, l, next_state = 100, err_state = 100, t_state;
gboolean valid_folding = FALSE;
guint nlines_count[RSPAMD_TASK_NEWLINES_MAX];
- guint order = 0;
+ guint norder = 0;
p = in;
end = p + len;
@@ -334,16 +339,16 @@ rspamd_mime_headers_process (struct rspamd_task *task, GHashTable *target,
/* We also validate utf8 and replace all non-valid utf8 chars */
rspamd_mime_charset_utf_enforce (nh->decoded, strlen (nh->decoded));
- rspamd_mime_header_add (task, target, nh, check_newlines);
- nh->order = order ++;
+ rspamd_mime_header_add (task, target, order, nh, check_newlines);
+ nh->order = norder ++;
state = 0;
break;
case 5:
/* Header has only name, no value */
nh->value = "";
nh->decoded = "";
- rspamd_mime_header_add (task, target, nh, check_newlines);
- nh->order = order ++;
+ rspamd_mime_header_add (task, target, order, nh, check_newlines);
+ nh->order = norder ++;
state = 0;
break;
case 99: