From 8d5b22bd09a41a29c66cf8ce26c4c0d80bb04b56 Mon Sep 17 00:00:00 2001 From: Ben Cotterell Date: Tue, 18 Jun 2019 20:16:41 +0100 Subject: [PATCH] Don't expect trailing space on command completion While trying to see why I couldn't get my emails from an Exchange server I found this: [imap]: 41:31.42 someserver.com handler _put_response(IOMC1 OK) [imap]: 41:31.42 someserver.com handler unexpected response: 'IOMC1 OK' And shortly after that the connection was closed. IOMC1 is just the unique tag for the session. The pattern looks for the tag, a number, a word like "OK" or something, *then a space*, then optionally some data. If the data aren't there it shouldn't be expecting a space. Signed-off-by: Nicolas Sebrecht --- offlineimap/bundled_imaplib2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offlineimap/bundled_imaplib2.py b/offlineimap/bundled_imaplib2.py index 1fd47d2..7d04f68 100755 --- a/offlineimap/bundled_imaplib2.py +++ b/offlineimap/bundled_imaplib2.py @@ -342,7 +342,7 @@ class IMAP4(object): self.tagpre = Int2AP(random.randint(4096, 65535)) self.tagre = re.compile(r'(?P' + self.tagpre - + r'\d+) (?P[A-Z]+) (?P.*)') + + r'\d+) (?P[A-Z]+) ?(?P.*)') self._mode_ascii() # Only option in py2