Jason Wright | 4 Jun 2012 18:18

lotus imap + offlineimap bug

When using a Lotus IMAP server, offlineimap barfs.  It's because it returns a string like: "\\\\" which is not correctly unescaped (as '\\').  The regular expression for matching quotes assumes that any \ followed by quote is an escaped quote... not true: \\" is a literal \ followed by a non-escaped quote.

So, the solution is to use a better regex. I'd love to take credit for the regex, but I cribbed the regex from:


Log and patch are below.

--Jason L. Wright

Log of problem:

 [imap]:   07:27.96 my-imap-server.example.com handler untagged_responses[OK] 0 += ["Domino IMAP4 Server Release 7.0.4FP1 HF143 ready Mon, 4 Jun 2012 10:07:27 -0600"]

...

 [imap]:   07:31.26 Account sync Test _untagged_response(OK, ?, LIST) => ['(\\Noselect) "\\\\" ""']
 ERROR: While attempting to sync account 'Test'
  'NoneType' object has no attribute 'group'
 [imap]:   07:31.26 my-imap-server.example.com handler LIST:PILN4.ready.set
Account sync Test:
 ['  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 234, in syncrunner\n    self.sync()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 290, in sync\n    remoterepos.getfolders()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/repository/IMAP.py", line 268, in getfolders\n    imapobj = self.imapserver.acquireconnection()\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/imapserver.py", line 294, in acquireconnection\n    imaputil.imapsplit(listres[0])[1:]\n', '  File "/usr/lib/python2.7/site-packages/offlineimap/imaputil.py", line 148, in imapsplit\n    retval.append(m.group(\'quote\'))\n']

patch:

diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py
index 557064b..10404dd 100644
--- a/offlineimap/imaputil.py
+++ b/offlineimap/imaputil.py
<at> <at> -23,8 +23,8 <at> <at> from offlineimap.ui import getglobalui
 
 # find the first quote in a string
 quotere = re.compile(
-    r"""(?P<quote>"(?:\\"|[^"])*") # Quote, possibly containing encoded
-                                   # quotation mark
+    r"""(?P<quote>"[^\"\\]*(?:\\.|[^"\\])*")   # Quote, possibly containing
+                                               # encoded quotation mark
         \s*(?P<rest>.*)$           # Whitespace & remainder of string""",
     re.VERBOSE)

_______________________________________________
OfflineIMAP-project mailing list
OfflineIMAP-project <at> lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project

OfflineIMAP homepage: http://software.complete.org/offlineimap

Gmane