]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix all headers iteration
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Feb 2020 12:31:50 +0000 (12:31 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Feb 2020 12:31:50 +0000 (12:31 +0000)
src/libmime/mime_parser.c
src/lua/lua_mimepart.c
src/lua/lua_task.c

index d989a8e2ea608f988c234d0606ac4af3cffa8e5e..ce816240148932b30a5ccf05ab415226ad67794b 100644 (file)
@@ -707,6 +707,11 @@ rspamd_mime_process_multipart_node (struct rspamd_task *task,
                                        npart->raw_headers_str,
                                        npart->raw_headers_len,
                                        FALSE);
+
+                       /* Preserve the natural order */
+                       if (npart->headers_order) {
+                               LL_REVERSE2 (npart->headers_order, ord_next);
+                       }
                }
 
                hdr = rspamd_message_get_header_from_hash (npart->raw_headers,
@@ -1265,6 +1270,11 @@ rspamd_mime_parse_message (struct rspamd_task *task,
                                                TRUE);
                                npart->raw_headers = rspamd_message_headers_ref (
                                                MESSAGE_FIELD (task, raw_headers));
+
+                               /* Preserve the natural order */
+                               if (MESSAGE_FIELD (task, headers_order)) {
+                                       LL_REVERSE2 (MESSAGE_FIELD (task, headers_order), ord_next);
+                               }
                        }
 
                        hdr = rspamd_message_get_header_from_hash (
@@ -1290,6 +1300,11 @@ rspamd_mime_parse_message (struct rspamd_task *task,
                                                        TRUE);
                                        npart->raw_headers = rspamd_message_headers_ref (
                                                        MESSAGE_FIELD (task, raw_headers));
+
+                                       /* Preserve the natural order */
+                                       if (MESSAGE_FIELD (task, headers_order)) {
+                                               LL_REVERSE2 (MESSAGE_FIELD (task, headers_order), ord_next);
+                                       }
                                }
 
                                hdr = rspamd_message_get_header_from_hash (
@@ -1341,6 +1356,11 @@ rspamd_mime_parse_message (struct rspamd_task *task,
                                                npart->raw_headers_str,
                                                npart->raw_headers_len,
                                                FALSE);
+
+                               /* Preserve the natural order */
+                               if (npart->headers_order) {
+                                       LL_REVERSE2 (npart->headers_order, ord_next);
+                               }
                        }
 
                        hdr = rspamd_message_get_header_from_hash (npart->raw_headers,
index 7ce6d251d2f7b564b2e14a897989392ed3d3d14f..81e8bed59ebf75ecec36b7afdfa73cc41dd87e52 100644 (file)
@@ -2011,7 +2011,7 @@ lua_mimepart_headers_foreach (lua_State *L)
                if (part->headers_order) {
                        hdr = part->headers_order;
 
-                       LL_FOREACH (hdr, cur) {
+                       LL_FOREACH2 (hdr, cur, ord_next) {
                                if (re && re->re) {
                                        if (!rspamd_regexp_match (re->re, cur->name,
                                                        strlen (cur->name),FALSE)) {
index 58fbc193259b5f768da028b4cd4f214d08994a47..7fd99a55312baaec8f7130e5b7b0eb1a588932da 100644 (file)
@@ -6269,7 +6269,7 @@ lua_task_headers_foreach (lua_State *L)
                        if (MESSAGE_FIELD (task, headers_order)) {
                                hdr = MESSAGE_FIELD (task, headers_order);
 
-                               LL_FOREACH (hdr, cur) {
+                               LL_FOREACH2 (hdr, cur, ord_next) {
                                        if (re && re->re) {
                                                if (!rspamd_regexp_match (re->re, cur->name,
                                                                strlen (cur->name), FALSE)) {