commit 5f775f8: [Fix] Fix all headers iteration
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Feb 7 12:35:08 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-02-07 12:31:50 +0000
URL: https://github.com/rspamd/rspamd/commit/5f775f8c3d916bf09c5791518b73d2cc548cf89b (HEAD -> master)
[Fix] Fix all headers iteration
---
src/libmime/mime_parser.c | 20 ++++++++++++++++++++
src/lua/lua_mimepart.c | 2 +-
src/lua/lua_task.c | 2 +-
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c
index d989a8e2e..ce8162401 100644
--- a/src/libmime/mime_parser.c
+++ b/src/libmime/mime_parser.c
@@ -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,
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 7ce6d251d..81e8bed59 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -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)) {
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 58fbc1932..7fd99a553 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -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)) {
More information about the Commits
mailing list