commit f8af1c1: [Minor] Append header to the ordered list of headers if it does not exist
Vsevolod Stakhov
vsevolod at rspamd.com
Mon Jul 29 17:49:20 UTC 2024
Author: Vsevolod Stakhov
Date: 2023-11-25 12:42:59 +0000
URL: https://github.com/rspamd/rspamd/commit/f8af1c1f2fea4c1c1eda945578eb8c16e7358ef3
[Minor] Append header to the ordered list of headers if it does not exist
---
src/libmime/mime_headers.c | 7 ++++++-
src/libmime/mime_headers.h | 9 +++++----
src/lua/lua_task.c | 5 ++++-
3 files changed, 15 insertions(+), 6 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
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index fe6e498c9..727860208 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -6750,7 +6750,10 @@ lua_task_modify_header(lua_State *L)
ucl_object_t *mods = ucl_object_lua_import(L, 3);
rspamd_message_set_modified_header(task,
- MESSAGE_FIELD_CHECK(task, raw_headers), hname, mods);
+ MESSAGE_FIELD(task, raw_headers),
+ hname,
+ mods,
+ &(MESSAGE_FIELD(task, headers_order)));
ucl_object_unref(mods);
lua_pushboolean(L, true);
More information about the Commits
mailing list