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 <nicolas.s-dev@laposte.net>
This commit is contained in:
Ben Cotterell 2019-06-18 20:16:41 +01:00 committed by Nicolas Sebrecht
parent 8406ba3bb4
commit 8d5b22bd09

View File

@ -342,7 +342,7 @@ class IMAP4(object):
self.tagpre = Int2AP(random.randint(4096, 65535)) self.tagpre = Int2AP(random.randint(4096, 65535))
self.tagre = re.compile(r'(?P<tag>' self.tagre = re.compile(r'(?P<tag>'
+ self.tagpre + self.tagpre
+ r'\d+) (?P<type>[A-Z]+) (?P<data>.*)') + r'\d+) (?P<type>[A-Z]+) ?(?P<data>.*)')
self._mode_ascii() # Only option in py2 self._mode_ascii() # Only option in py2