<div>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.</div>
<div><br></div><div>So, the solution is to use a better regex. I'd love to take credit for the regex, but I cribbed the regex from:</div><div><br></div><div><a href="http://stackoverflow.com/questions/2148587/regex-quoted-string-with-escaped-quotes-in-c-sharp">http://stackoverflow.com/questions/2148587/regex-quoted-string-with-escaped-quotes-in-c-sharp</a></div>
<div><br></div><div>Log and patch are below.</div><div><br></div><div>--Jason L. Wright</div><div><br></div><div><div>Log of problem:</div><div><br></div><div> [imap]: 07:27.96 <a href="http://my-imap-server.example.com">my-imap-server.example.com</a> handler untagged_responses[OK] 0 += ["Domino IMAP4 Server Release 7.0.4FP1 HF143 ready Mon, 4 Jun 2012 10:07:27 -0600"]</div>
<div><br></div><div>...</div><div><br></div><div> [imap]: 07:31.26 Account sync Test _untagged_response(OK, ?, LIST) => ['(\\Noselect) "\\\\" ""']</div><div> ERROR: While attempting to sync account 'Test'</div>
<div> 'NoneType' object has no attribute 'group'</div><div><a href="http://my-imap-server.example.com">my-imap-server.example.com</a> handler:</div><div> [imap]: 07:31.26 <a href="http://my-imap-server.example.com">my-imap-server.example.com</a> handler LIST:PILN4.ready.set</div>
<div>Account sync Test:</div><div> [' 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']</div>
</div><div><br></div><div><div>patch:</div><div><br></div><div>diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py</div><div>index 557064b..10404dd 100644</div><div>--- a/offlineimap/imaputil.py</div><div>+++ b/offlineimap/imaputil.py</div>
<div>@@ -23,8 +23,8 @@ from offlineimap.ui import getglobalui</div><div> </div><div> # find the first quote in a string</div><div> quotere = re.compile(</div><div>- r"""(?P<quote>"(?:\\"|[^"])*") # Quote, possibly containing encoded</div>
<div>- # quotation mark</div><div>+ r"""(?P<quote>"[^\"\\]*(?:\\.|[^"\\])*") # Quote, possibly containing</div><div>+ # encoded quotation mark</div>
<div> \s*(?P<rest>.*)$ # Whitespace & remainder of string""",</div><div> re.VERBOSE)</div></div><div><br></div>