Am Fri, 23. May 2008, 14:41:21 -0500 schrieb John Goerzen: > I do think I see the bug here. It looks for the first \r\n, which > normally would be a different header. Looks like there is the need for > some more intelligence. Thank you for the report; I will think about > this some more yet.
Hi! I've thought about this as well. I assume the offlineimap doesn't insert its own header right at the top because there might be a "From " line (although there shouldn't be in maildir format). So I've created a patch which inserts the header right at the top, if there is no "From " line, and after the from line if there is one. It works for me, but (1) the case with a "From " line is untested, (2) I'm a bit uncertain how I should report a mail format error, and (3) I have no python experience at all. ====================================================================== diff -ur offlineimap-6.0.0/offlineimap/folder/IMAP.py offlineimap-6.0.0+joe1/offlineimap/folder/IMAP.py --- offlineimap-6.0.0/offlineimap/folder/IMAP.py 2008-05-11 04:04:20.000000000 +0200 +++ offlineimap-6.0.0+joe1/offlineimap/folder/IMAP.py 2008-05-25 14:36:28.000000000 +0200 @@ -189,16 +189,16 @@ ui.debug('imap', 'savemessage_addheader: called to add %s: %s' % (headername, headervalue)) - insertionpoint = content.find("\r\n") + insertionpoint = 0 + if content[0:5] == "From ": + insertionpoint = content.find("\r\n") + if insertionpoint == -1: + raise ValueError, "Message is not in RFC822 format: %s" % repr(content) + insertionpoint += 2 ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint) leader = content[0:insertionpoint] ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader)) - if insertionpoint == 0 or insertionpoint == -1: - newline = '' - insertionpoint = 0 - else: - newline = "\r\n" - newline += "%s: %s" % (headername, headervalue) + newline = "%s: %s\r\n" % (headername, headervalue) ui.debug('imap', 'savemessage_addheader: newline = ' + repr(newline)) trailer = content[insertionpoint:] ui.debug('imap', 'savemessage_addheader: trailer = ' + repr(trailer)) ====================================================================== The other option is probably to look for the end of headers ("\r\n\r\n") and insert the new header there. Thanks, Jö. -- In the shower, time can be measured only by the fluctuations of the temperature.
signature.asc
Description: Digital signature