summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-01-24 15:01:33 -0800
committerKevin McCarthy <kevin@8t8.us>2021-01-24 15:11:12 -0800
commit3d6e7df769841f34227a9065401c193b756efde2 (patch)
tree14674e3e72273ce066a8ebbaf33852af36483d41 /copy.c
parentc6700b05bc7d879fc23903b0023c7274e7bdfcd4 (diff)
Fix hdr_order to use the longest match.
Previously, Mutt would find the first match and use that. However, the example shown in the manual: hdr_order From Date: From: To: Cc: Subject: gives the expectation that an mbox From_ line would print first, then the Date:, and then the From: header. Change the matcher to scan all HeaderOrderList entries and use the longest match. Update the documentation to make it clear From_ lines are printed out with other "real" headers, and can be manipulated via ignore and hdr_order commands.
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/copy.c b/copy.c
index 4dc7399b..ca179dd6 100644
--- a/copy.c
+++ b/copy.c
@@ -231,14 +231,24 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER)
{
+ int match = -1;
+ size_t match_len, hdr_order_len;
+
for (t = HeaderOrderList, x = 0 ; (t) ; t = t->next, x++)
{
- if (!ascii_strncasecmp (buf, t->data, mutt_strlen (t->data)))
+ hdr_order_len = mutt_strlen (t->data);
+ if (!ascii_strncasecmp (buf, t->data, hdr_order_len))
{
+ if ((match == -1) || (hdr_order_len > match_len))
+ {
+ match = x;
+ match_len = hdr_order_len;
+ }
dprint(2, (debugfile, "Reorder: %s matches %s\n", t->data, buf));
- break;
}
}
+ if (match != -1)
+ x = match;
}
ignore = 0;