[Dovecot] possible bug with mail->get_header and caching?

Johannes Berg johannes at sipsolutions.net
Mon Dec 27 09:08:29 EET 2004


I don't know if this is intended or not, but here it comes.

I have
 * that copy plugin I was working on
 * dovecot 1.0-test59
 * thunderbird test client

My copy plugin looks for the X-DSPAM-Signature header line, and reports 
it to syslog as such:
imap: we have a signature: "X-DSPAM-Signature: <sig>"
where <sig> is replaced by what is found in the header line. This only 
happens when I copy in/out of the SPAM folder (which works fine).

Now, when a mail is copied from INBOX to SPAM that doesn't have the 
signature line, I return an error to the client saying the user can't do 
that copy since the signature line is necessary. I detect the condition 
of not having that signature line by checking like this:
if (!(signature = mail->get_header(mail, "X-DSPAM-Signature")) {
... return error ...
}

This works fine, error comes back.

Second try, copying a mail that has the header line: works.

So, lets do some code changes, disconnect and reconnect to reload the 
plugin. All of a sudden, copying mails that don't have the header line 
works too! Uhh? Lets go looking at syslog:
imap: we have a signature: "X-DSPAM-Signature: "

The only rational explanation I could come up with is that dovecot 
caches the header line and somehow decided that since it knows about the 
X-DSPAM-Signature header line mails that don't contain it should have an 
empty version of it. Well, I can of course test for this (and I actually 
should anyway, an empty signature isn't useful to dspam), but I do think 
this is a bug since it makes distinguishing between empty and 
non-present header lines impossible.

Regards,
johannes




More information about the dovecot mailing list