Changeset 5474:d3ee9644765f

Show
Ignore:
Timestamp:
2008-07-10 06:38:25 (5 months ago)
Author:
Aron Griffis <agriffis@…>
Branch:
HEAD
Message:

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 <agriffis@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • copy.c

    r5466 r5474  
    363363  } 
    364364 
    365   if (flags & CH_UPDATE) 
    366   { 
    367     if ((flags & CH_NOSTATUS) == 0) 
    368     { 
    369       if (h->env->irt_changed && h->env->in_reply_to) 
    370       { 
    371         LIST *listp = h->env->in_reply_to; 
    372         fputs ("In-Reply-To:", out); 
    373         for (; listp; listp = listp->next) 
    374         { 
    375           fputc (' ', out); 
    376           fputs (listp->data, out); 
    377         } 
    378         fputc ('\n', out); 
    379       } 
    380  
    381       if (h->env->refs_changed && h->env->references) 
    382       { 
    383         fputs ("References:", out); 
    384         mutt_write_references (h->env->references, out, 0); 
    385         fputc ('\n', out); 
    386       } 
    387  
    388       if (h->old || h->read) 
    389       { 
    390         fputs ("Status: ", out); 
    391         if (h->read) 
    392           fputs ("RO", out); 
    393         else if (h->old) 
    394           fputc ('O', out); 
    395         fputc ('\n', out); 
    396       } 
    397  
    398       if (h->flagged || h->replied) 
    399       { 
    400         fputs ("X-Status: ", out); 
    401         if (h->replied) 
    402           fputc ('A', out); 
    403         if (h->flagged) 
    404           fputc ('F', out); 
    405         fputc ('\n', out); 
    406       } 
     365  if ((flags & CH_UPDATE_IRT) && h->env->in_reply_to) 
     366  { 
     367    LIST *listp = h->env->in_reply_to; 
     368    fputs ("In-Reply-To:", out); 
     369    for (; listp; listp = listp->next) 
     370    { 
     371      fputc (' ', out); 
     372      fputs (listp->data, out); 
     373    } 
     374    fputc ('\n', out); 
     375  } 
     376 
     377  if ((flags & CH_UPDATE_REFS) && h->env->references) 
     378  { 
     379    fputs ("References:", out); 
     380    mutt_write_references (h->env->references, out, 0); 
     381    fputc ('\n', out); 
     382  } 
     383 
     384  if ((flags & CH_UPDATE) && (flags & CH_NOSTATUS) == 0) 
     385  { 
     386    if (h->old || h->read) 
     387    { 
     388      fputs ("Status: ", out); 
     389      if (h->read) 
     390        fputs ("RO", out); 
     391      else if (h->old) 
     392        fputc ('O', out); 
     393      fputc ('\n', out); 
     394    } 
     395 
     396    if (h->flagged || h->replied) 
     397    { 
     398      fputs ("X-Status: ", out); 
     399      if (h->replied) 
     400        fputc ('A', out); 
     401      if (h->flagged) 
     402        fputc ('F', out); 
     403      fputc ('\n', out); 
    407404    } 
    408405  }