diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-23 16:13:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-23 16:13:01 +0000 |
commit | d7f8c974de88492c37d5b750eb463043c9d0e602 (patch) | |
tree | 0dc10b6faec52941e341349a53390da19a381103 /src/libmime | |
parent | 2237481903caa32c1b5d5042aaaca0f5ce11e0f1 (diff) | |
download | rspamd-d7f8c974de88492c37d5b750eb463043c9d0e602.tar.gz rspamd-d7f8c974de88492c37d5b750eb463043c9d0e602.zip |
[Project] Handle new modification
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/mime_headers.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index 832e1306d..dbedff9e4 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -1838,10 +1838,11 @@ rspamd_message_set_modified_header (struct rspamd_task *task, } /* - * Next, we return all headers modified to the existing chain - * This implies an additional copy of all structures but is safe enough to - * deal with it - */ + * Next, we return all headers modified to the existing chain + * This implies an additional copy of all structures but is safe enough to + * deal with it + */ + cur_hdr->flags |= RSPAMD_HEADER_MODIFIED; cur_hdr->modified_chain = NULL; gint new_chain_length = 0; @@ -1868,6 +1869,20 @@ rspamd_message_set_modified_header (struct rspamd_task *task, /* We can not deal with headers additions */ elt = ucl_object_lookup (obj, "add"); if (elt && ucl_object_type (elt) == UCL_ARRAY) { + if (!(hdr_elt->flags & RSPAMD_HEADER_MODIFIED)) { + /* Copy the header itself to the modified chain */ + struct rspamd_mime_header *nhdr; + hdr_elt->flags |= RSPAMD_HEADER_MODIFIED; + nhdr = rspamd_mempool_alloc ( + task->task_pool, sizeof (*nhdr)); + memcpy (nhdr, hdr_elt, sizeof (*hdr_elt)); + nhdr->modified_chain = NULL; + nhdr->modified_chain->next = NULL; + nhdr->ord_next = NULL; + nhdr->prev = nhdr; + hdr_elt->modified_chain = nhdr; + } + /* * add: {{1, "foo"}, {-1, "bar"} ...} * where number is the header's position starting from '1' |