lotus imap + offlineimap bug

Jason Wright jason at thought.net
Mon Jun 4 17:18:22 BST 2012


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:

http://stackoverflow.com/questions/2148587/regex-quoted-string-with-escaped-quotes-in-c-sharp

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'
my-imap-server.example.com handler:
 [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
@@ -23,8 +23,8 @@ 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20120604/b6927c43/attachment-0002.html>


More information about the OfflineIMAP-project mailing list