Open d9146081-23e3-446b-8cb0-51fe1da24a9b opened 12 years ago
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
@Joe sorry for the delay in getting back to you.
@David is this within your remit?
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):
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.
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: https://github.com/python/cpython/pull/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: ```python assignee = None closed_at = None created_at =
labels = ['3.7', '3.8', 'type-bug', 'library', 'expert-email']
title = 'imaplib: Mailbox names are not quoted'
updated_at =
user = 'https://bugs.python.org/joebauer'
```
bugs.python.org fields:
```python
activity =
actor = 'mcepl'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)', 'email']
creation =
creator = 'joebauer'
dependencies = []
files = ['41037']
hgrepos = []
issue_num = 13940
keywords = ['patch']
message_count = 8.0
messages = ['152612', '222160', '222175', '241131', '254418', '254634', '256127', '315084']
nosy_count = 6.0
nosy_names = ['barry', 'mcepl', 'r.david.murray', 'joebauer', 'maciej.szulik', 'bearbin']
pr_nums = ['6395']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue13940'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8']
```