X-OfflineIMAP header

Nicolas Sebrecht nicolas.s-dev at laposte.net
Thu Nov 18 18:56:15 GMT 2010


On Thu, Oct 07, 2010 at 01:47:43PM +0200, Johannes Stezenbach wrote:
> 
> even though the patch might not be applied to git
> due to lack of a maintainer, below is a simple patch
> which I think fixes the issue.  To test it I commented
> out two lines from folder/IMAP.py:
> 
>     def savemessage_searchforheader(self, imapobj, headername, headervalue):
>         #if imapobj.untagged_responses.has_key('APPENDUID'):
>         #    return long(imapobj.untagged_responses['APPENDUID'][-1].split(' ')[1])
> 
> Then the UID SEARCH command is executed with my IMAP servers and
> returned the desired result.

> --- snip ---

Use the scissors line form as supported by git. Something like

-- >8 --

or

-- >8 -- snip -- >8 --

is correct.

> From 0e7e5874d62ebbde4fa468fd276c1622b526c46d Mon Sep 17 00:00:00 2001

This line is not valid.

> From: Johannes Stezenbach <js at sig21.net>
> Date: Thu, 7 Oct 2010 12:33:27 +0200
> Subject: [PATCH] Change X-OfflineIMAP header format
> 
> Change the X-OfflineIMAP header to work around possible Exchange MAPI
> table overflow problem described in
> http://article.gmane.org/gmane.mail.imap.offlineimap.general/1699
> (It is unknown whether this problem still exits in current
> Exchange versions, but let's assume the worst.)
> 
> The X-OfflineIMAP header is neccessary with some IMAP servers to
> reliably determine the UID of a new messages uploaded to the server
> by using the "UID SEARCH HEADER name string" command.  Since this
> command compares header name and value it is sufficient to have
> a unique header value and a non-unique header name.
> 
> Note that a message can have more than one X-OfflineIMAP header if
> the message was copied between IMAP folders multiple times.

Is this fix reliable with already marked emails ?

> ---
>  offlineimap/folder/IMAP.py |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
> index c90d0e5..927c5f4 100644
> --- a/offlineimap/folder/IMAP.py
> +++ b/offlineimap/folder/IMAP.py
> @@ -220,10 +220,11 @@ class IMAPFolder(BaseFolder):
>          return self.messagelist[uid]['flags']
>  
>      def savemessage_getnewheader(self, content):
> -        headername = 'X-OfflineIMAP-%s-' % str(binascii.crc32(content)).replace('-', 'x')
> -        headername += binascii.hexlify(self.repository.getname()) + '-'
> -        headername += binascii.hexlify(self.getname())
> -        headervalue= '%d-' % long(time.time())
> +        headername = 'X-OfflineIMAP'
> +        headervalue = '%s-' % str(binascii.crc32(content)).replace('-', 'x')
> +        headervalue += binascii.hexlify(self.repository.getname()) + '-'
> +        headervalue += binascii.hexlify(self.getname())
> +        headervalue += '-%d-' % long(time.time())
>          headervalue += str(self.randomgenerator.random()).replace('.', '')
>          headervalue += '-v' + versionstr
>          return (headername, headervalue)

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list