You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
imaplib does not qupote mailbox names when it's sending it's query to the server in response to a status request, for example. This will lead to very strange errors if mailboxes are accessed which contain spaces:
i.e.
connection.status("mailbox name", "(MESSAGES)")
will return
File "/home/joe/test/imaplib.py", line 920, in \_command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: STATUS command error: BAD [b'Error in IMAP command STATUS: Status items must be list.']
which indicates that the error is within the actual flag list. It is not, however:
works as expected. This may arguably be or not be a bug -- however it is REALLY confusing to the user. Maybe at least a note should be included somewhere that -- just to be safe -- mailbox names should be quoted.
Any character which is one of the atom-specials (see the Formal
Syntax) will require that the mailbox name be represented as a
quoted string or literal.
Activity
joebauer commentedon Feb 4, 2012
imaplib does not qupote mailbox names when it's sending it's query to the server in response to a status request, for example. This will lead to very strange errors if mailboxes are accessed which contain spaces:
i.e.
will return
which indicates that the error is within the actual flag list. It is not, however:
works as expected. This may arguably be or not be a bug -- however it is REALLY confusing to the user. Maybe at least a note should be included somewhere that -- just to be safe -- mailbox names should be quoted.
All the best,
Joe
BreamoreBoy commentedon Jul 3, 2014
@joe sorry for the delay in getting back to you.
@david is this within your remit?
bitdancer commentedon Jul 3, 2014
Yes. It will be necessary to check the RFC to figure out what should be done here.
soltysh commentedon Apr 15, 2015
Joe is correct, according to the spec the names containing special chars (atom-specials) require names to be quoted (https://tools.ietf.org/html/rfc3501#section-5.1):
Syntax) will require that the mailbox name be represented as a
quoted string or literal.
I'll be working on a patch for that.
soltysh commentedon Nov 9, 2015
Currently working on a patch for this.
soltysh commentedon Nov 13, 2015
From imaplib.IMAP4 class description we're stating to quote parameters if necessary. This patch adds that capability according to https://tools.ietf.org/html/rfc3501#section-5.1
soltysh commentedon Dec 8, 2015
siemer thx for the comments in the review. I'll try to address them by the end of this week.
bearbin commentedon Apr 8, 2018
Pull Request opened on GH to fix this issue: #6395
vadmium commentedon Apr 18, 2024
Issue #92835 describes the cause of this bug
serhiy-storchaka commentedon Jul 5, 2026
Argument quoting has been restored in GH-152703. Closing as a duplicate of gh-40038.