imaplib: Mailbox names are not quoted #58148
Description
Activity
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:
connection.status("\"mailbox name\"", "(MESSAGES)")
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- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Feb 4, 2012 Yes. It will be necessary to check the RFC to figure out what should be done here.
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):
- 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.
I'll be working on a patch for that.
- Any character which is one of the atom-specials (see the Formal
Currently working on a patch for this.
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
siemer thx for the comments in the review. I'll try to address them by the end of this week.
Pull Request opened on GH to fix this issue: #6395
Issue #92835 describes the cause of this bug
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: