[Kde-pim] Messages without body

Ingo Klöcker kloecker at kde.org
Fri Jul 30 19:24:28 BST 2010


On Friday 30 July 2010, Kevin Krammer wrote:
> On Thursday, 2010-07-29, Ingo Klöcker wrote:
> > On Thursday 29 July 2010, Kevin Krammer wrote:
> > > Hi all,
> > > 
> > > while writing unit tests for item fetching from the MixedMaildir
> > > store, I've discovered inconsistencies between MBox and Maildir
> > > regarding messages without body.
> > > 
> > > The test data I am testing against has been created with KMail1,
> > > its the same four messages for both MBox and Maildir.
> > > I created all of them by sending new messages from one account to
> > > another,
> > > 
> > > For one of them I did not type anything into the main content
> > > area of the composer.
> > 
> > It seems KMail1 still adds an empty line as body (so it is not
> > possible to create a message without body with KMail1). As test I
> > created a message without body and a message with a single line of
> > text (but no newline). I saved both messages as drafts (the drafts
> > folder is mbox). After saving the message without body as draft
> > the drafts mbox ended with two empty lines (i.e. in total with
> > three '\n'). After saving the message with the single-line body as
> > draft the drafts mbox ended with the single-line (i.e. with a
> > single '\n').
> > 
> > Now it gets tricky. If the last message in an mbox file does
> > already end with an empty line (which is true for the message
> > without body) then KMail1 does not add an extra empty line when
> > appending the next message to the mbox file. OTOH, if the last
> > message in an mbox file does not end with an empty line then
> > KMail1 does (of course) add an extra empty line before appending
> > the next message to the mbox file.
> > 
> > IMO this is a bug in KMail1.
> 
> The question is which of the two is correct?
> The maildir version of the message I have also ends in two newlines,
> so does that mean the message in mbox (not at the end of the file)
> is wrong? (because it doesn't have two newlines followed by the
> separator newline?)

Yes. That's what I meant to say. KMail1 does not store messages ending 
with an empty line correctly in mbox files (or rather it does not 
separate such messages correctly from the next message when adding 
another message).


> > > But I first wanted to make sure it is not either a bug in
> > > libmaildir, libmbox or KMime. [2]
> > 
> > AFAICS there is no bug anywhere in libmaildir, libmbox or KMime.
> > But there is the above mentioned inconsistency in KMail1's writing
> > to mbox files and there is KMail1's inability to create messages
> > without body (even if they later appear to be messages without
> > body when reading them from an mbox file due to the former issue).
> 
> Should we make our new code consistent at least when writing?

Yes. Definitely.


> Which of the two behaviors would be the one?

If a new message is added to a non-empty mbox file then the following 
needs to be written to the mbox file:
- '\n' (i.e. the separating blank line)
- "From ...\n" (i.e. the "From " separator)
- the new message
- a '\n' if the new message does not end with a '\n'.

BTW, IMO the most authoritative specification of the mbox format can be 
found at http://qmail.org/man/man5/mbox.html


Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100730/528f435f/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list