[New-bugs-announce] [issue23678] imaplib status command cannot handle folder name containing whitespaces
bjshan
report at bugs.python.org
Mon Mar 16 10:31:53 CET 2015
New submission from bjshan:
imaplib status failed if the folder name contains whitespace.
For example,
c = IMAP4_SSL('hostname')
c = login(username, password)
c.status('Drafts', '(MESSAGES)') # would succeed
c.status('Apple Mail To Do', '(MESSAGES)') # would fail, error message is:
imaplib.error: STATUS command error: BAD [b"parse error: wrong character; expected '(' but got 'M'"]
It seems the status method could not properly parse the folder name "Apple Mail To Do", it recognizes only the first word "Apple", then failed when meeting the following word "Mail".
I checked imaplib.py, _command 's definition looks like the cause, but I am not sure:
def _command(self, name, *args):
...
name = bytes(name, 'ASCII')
data = tag + b' ' + name
for arg in args:
if arg is None: continue
if isinstance(arg, str):
arg = bytes(arg, "ASCII")
data = data + b' ' + arg
Work around for this:
Manually add double quote around the folder name, like:
'"' + mailbox_name + '"'
BUT,
while c.status('"Apple Mail To Do"', '(MESSAGES)') worked,
c.status("'Apple Mail To Do'", '(MESSAGES)') failed. Suggesting single and double quote weighs not the same?
----------
components: Library (Lib)
messages: 238188
nosy: bjshan
priority: normal
severity: normal
status: open
title: imaplib status command cannot handle folder name containing whitespaces
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23678>
_______________________________________
More information about the New-bugs-announce
mailing list