Skip to content

Commit

Permalink
[Fix] Fix all headers iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Feb 7, 2020
1 parent 3ced568 commit 5f775f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/libmime/mime_parser.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/lua/lua_mimepart.c
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/lua/lua_task.c
Expand Up @@ -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)) {
Expand Down

0 comments on commit 5f775f8

Please sign in to comment.