[PATCH 1/4] Include message header at better place

Vladimir.Marek at oracle.com Vladimir.Marek at oracle.com
Tue Jul 26 09:59:53 BST 2011


From: Vladimir Marek <vlmarek at volny.cz>

It's not enough to place header after first newline, since this might break
multiline rfc0822 folded long header lines. Those are difined as CRLF followed
by white space. Instead we'll search for two successive CRLF sequences which
mark end of mail headers and place our header just before that.

Signed-off-by: Vladimir Marek <vlmarek at volny.cz>
---
 offlineimap/folder/IMAP.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index 9297a7b..19a0340 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -276,7 +276,7 @@ class IMAPFolder(BaseFolder):
         self.ui.debug('imap',
                  'savemessage_addheader: called to add %s: %s' % (headername,
                                                                   headervalue))
-        insertionpoint = content.find("\r\n")
+        insertionpoint = content.find("\r\n\r\n")
         self.ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint)
         leader = content[0:insertionpoint]
         self.ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader))
-- 
1.7.3.2





More information about the OfflineIMAP-project mailing list