Include message header at better place

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@volny.cz>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Vladimir Marek 2011-07-26 10:59:53 +02:00 committed by Nicolas Sebrecht
parent 86cfd31ce9
commit 86e9c7442b

View File

@ -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))