• David Champion's avatar
    Invalidate header caches when spam rules change. closes #3473 · 957c3a0a
    David Champion authored
    User 'exg' on #mutt reported a problem when using header cache with IMAP
    and spam rules.  Spam tags are retrieved from cache and not updated when
    spam rules change.
    1. Enable header caching in muttrc
    2. Set spam rules in muttrc
    3. Use IMAP (or POP or Maildir).  Your spam rules store spam tags into
       your message headers, and these get cached.
    4. Quit mutt
    5. Change your spam rules in muttrc
    6. Relaunch mutt
    7. Because of header caching, the rfc822 headers are not reparsed, and
       spam rules are not reapplied.  User has outdated spam tags.
    Spam rules are applied during rfc822 header parsing because it's the
    only time we get a full and unadulterated view of all headers.  Once
    header parse is done we have only processed headers and 'user headers'
    (X-headers).  We might do spam rule matching against the struct HEADER
    copy of headers, except that:
    a. the header might not be in HEADER if it's non-standard and not an
    b. spam rules are regular expressions matching any arbitrary header
       line, and we would need to map these regexps to the header used to
       create the HEADER fields.  This would change the syntax and behavior
       of spam rules dramatically.
    One solution, perhaps stopgap, is to invalidate the header cache when
    spam rules change.  That's what this patch does.  It alters the hcache
    versioning algorithm so that in addition to using the compiled-in
    checksum of mutt's structures definitions, we also mix in the user's
    runtime spam rules.  Any time spam rules change the hcachever hash value
    changes, causing the hcache to be rewritten.
hcache.c 24.8 KB