aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-11-25 12:42:59 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-11-25 12:42:59 +0000
commitf8af1c1f2fea4c1c1eda945578eb8c16e7358ef3 (patch)
treebb2be5678d2222c3a87d5a35635c961fe8c6131d /src/libmime
parent372c476e2ae73ca50069d8616033e4702f498b31 (diff)
downloadrspamd-f8af1c1f2fea4c1c1eda945578eb8c16e7358ef3.tar.gz
rspamd-f8af1c1f2fea4c1c1eda945578eb8c16e7358ef3.zip
[Minor] Append header to the ordered list of headers if it does not exist
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/mime_headers.c7
-rw-r--r--src/libmime/mime_headers.h9
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index e0cf42e0a..2b6b2acc0 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -1028,7 +1028,8 @@ rspamd_message_headers_new(void)
void rspamd_message_set_modified_header(struct rspamd_task *task,
struct rspamd_mime_headers_table *hdrs,
const gchar *hdr_name,
- const ucl_object_t *obj)
+ const ucl_object_t *obj,
+ struct rspamd_mime_header **order_ptr)
{
khiter_t k;
khash_t(rspamd_mime_headers_htb) *htb = &hdrs->htb;
@@ -1048,6 +1049,10 @@ void rspamd_message_set_modified_header(struct rspamd_task *task,
k = kh_put(rspamd_mime_headers_htb, htb, hdr_elt->name, &r);
kh_value(htb, k) = hdr_elt;
+
+ if (order_ptr) {
+ DL_APPEND(*order_ptr, hdr_elt);
+ }
}
else {
hdr_elt = kh_value(htb, k);
diff --git a/src/libmime/mime_headers.h b/src/libmime/mime_headers.h
index 7e3cf8420..ffa863e8b 100644
--- a/src/libmime/mime_headers.h
+++ b/src/libmime/mime_headers.h
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -143,7 +143,8 @@ rspamd_message_get_header_from_hash(struct rspamd_mime_headers_table *hdrs,
void rspamd_message_set_modified_header(struct rspamd_task *task,
struct rspamd_mime_headers_table *hdrs,
const gchar *hdr_name,
- const ucl_object_t *obj);
+ const ucl_object_t *obj,
+ struct rspamd_mime_header **order_ptr);
/**
* Cleans up hash table of the headers