From 69abd0e6566183a69daf6b67f7739f738206c433 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Fri, 4 Jun 2004 21:29:24 +0100 Subject: [PATCH] /offlineimap/head: changeset 578 Applied patch from Daniel James to adjust the insertion point for a new header. --- offlineimap/head/debian/changelog | 2 ++ offlineimap/head/offlineimap/folder/IMAP.py | 24 +++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/offlineimap/head/debian/changelog b/offlineimap/head/debian/changelog index c5acc18..330017f 100644 --- a/offlineimap/head/debian/changelog +++ b/offlineimap/head/debian/changelog @@ -9,6 +9,8 @@ offlineimap (4.0.3) unstable; urgency=low Closes: #252645. * Fixed typos in manual. Closes: #252646. * Regenerated docs. + * Applied patch from Daniel James to adjust the insertion point + for a new header. -- John Goerzen Fri, 4 Jun 2004 10:10:00 -0500 diff --git a/offlineimap/head/offlineimap/folder/IMAP.py b/offlineimap/head/offlineimap/folder/IMAP.py index 2381c57..4cc4b19 100644 --- a/offlineimap/head/offlineimap/folder/IMAP.py +++ b/offlineimap/head/offlineimap/folder/IMAP.py @@ -126,20 +126,22 @@ class IMAPFolder(BaseFolder): ui.debug('imap', 'savemessage_addheader: called to add %s: %s' % (headername, headervalue)) + newline = "%s: %s" % (headername, headervalue) + ui.debug('imap', 'savemessage_addheader: newline = ' + repr(newline)) + insertionpoint = content.find("\r\n") 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 + + if insertionpoint == -1: + return newline + "\r\n" + content + elif insertionpoint == 0: + return newline + content else: - newline = "\r\n" - newline += "%s: %s" % (headername, headervalue) - ui.debug('imap', 'savemessage_addheader: newline = ' + repr(newline)) - trailer = content[insertionpoint:] - ui.debug('imap', 'savemessage_addheader: trailer = ' + repr(trailer)) - return leader + newline + trailer + leader = content[0:insertionpoint] + ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader)) + trailer = content[insertionpoint:] + ui.debug('imap', 'savemessage_addheader: trailer = ' + repr(trailer)) + return leader + "\r\n" + newline + trailer def savemessage_searchforheader(self, imapobj, headername, headervalue): if imapobj.untagged_responses.has_key('APPENDUID'):