From: Aron Griffis Date: Thu, 10 Jul 2008 13:38:25 +0000 (-0400) Subject: Fix three bugs handling flags in mutt_copy_header X-Git-Tag: mutt-1-5-19-rel~173 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18e36ad9759b35d64d8d9c67b9501c70fd40fa4c;p=mutt Fix three bugs handling flags in mutt_copy_header 1. mutt_copy_header incorrectly tests CH_UPDATE to determine whether to write the In-Reply-To and References headers. CH_UPDATE refers only to Status: and X-Status: 2. mutt_copy_header ignores CH_NOSTATUS which is supposed to indicate that the mailbox type doesn't use those headers. 3. mutt_copy_header tests h->env->irt_changed and h->env->refs_changed when it should be testing CH_UPDATE_IRT and CH_UPDATE_REFS, respectively. Early in the function this happens: if (h->env) flags |= (h->env->irt_changed ? CH_UPDATE_IRT : 0) | (h->env->refs_changed ? CH_UPDATE_REFS : 0); This means that for most callers, the result is the same, but mutt_copy_header should be testing the flags because the caller might have set them explicitly without setting irt_changed/refs_changed. Signed-off-by: Aron Griffis --- diff --git a/copy.c b/copy.c index ad706a85..fa283200 100644 --- a/copy.c +++ b/copy.c @@ -362,48 +362,45 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) fputc('\n', out); } - if (flags & CH_UPDATE) + if ((flags & CH_UPDATE_IRT) && h->env->in_reply_to) { - if ((flags & CH_NOSTATUS) == 0) + LIST *listp = h->env->in_reply_to; + fputs ("In-Reply-To:", out); + for (; listp; listp = listp->next) { - if (h->env->irt_changed && h->env->in_reply_to) - { - LIST *listp = h->env->in_reply_to; - fputs ("In-Reply-To:", out); - for (; listp; listp = listp->next) - { - fputc (' ', out); - fputs (listp->data, out); - } - fputc ('\n', out); - } + fputc (' ', out); + fputs (listp->data, out); + } + fputc ('\n', out); + } - if (h->env->refs_changed && h->env->references) - { - fputs ("References:", out); - mutt_write_references (h->env->references, out, 0); - fputc ('\n', out); - } + if ((flags & CH_UPDATE_REFS) && h->env->references) + { + fputs ("References:", out); + mutt_write_references (h->env->references, out, 0); + fputc ('\n', out); + } - if (h->old || h->read) - { - fputs ("Status: ", out); - if (h->read) - fputs ("RO", out); - else if (h->old) - fputc ('O', out); - fputc ('\n', out); - } + if ((flags & CH_UPDATE) && (flags & CH_NOSTATUS) == 0) + { + if (h->old || h->read) + { + fputs ("Status: ", out); + if (h->read) + fputs ("RO", out); + else if (h->old) + fputc ('O', out); + fputc ('\n', out); + } - if (h->flagged || h->replied) - { - fputs ("X-Status: ", out); - if (h->replied) - fputc ('A', out); - if (h->flagged) - fputc ('F', out); - fputc ('\n', out); - } + if (h->flagged || h->replied) + { + fputs ("X-Status: ", out); + if (h->replied) + fputc ('A', out); + if (h->flagged) + fputc ('F', out); + fputc ('\n', out); } }