python / cpython

The Python programming language
https://www.python.org
Other
63.33k stars 30.31k forks source link

imaplib: Mailbox names are not quoted #58148

Open d9146081-23e3-446b-8cb0-51fe1da24a9b opened 12 years ago

d9146081-23e3-446b-8cb0-51fe1da24a9b commented 12 years ago
BPO 13940
Nosy @warsaw, @mcepl, @bitdancer, @soltysh, @bearbin
PRs
  • python/cpython#6395
  • Files
  • issue13940.patch
  • 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'] ```

    d9146081-23e3-446b-8cb0-51fe1da24a9b commented 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

    83d2e70e-e599-4a04-b820-3814bbdb9bef commented 10 years ago

    @Joe sorry for the delay in getting back to you.

    @David is this within your remit?

    bitdancer commented 10 years ago

    Yes. It will be necessary to check the RFC to figure out what should be done here.

    soltysh commented 9 years ago

    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.

    soltysh commented 8 years ago

    Currently working on a patch for this.

    soltysh commented 8 years ago

    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 commented 8 years ago

    siemer thx for the comments in the review. I'll try to address them by the end of this week.

    18254c50-0e04-4128-aa00-83f4c76f693a commented 6 years ago

    Pull Request opened on GH to fix this issue: https://github.com/python/cpython/pull/6395

    vadmium commented 6 months ago

    Issue #92835 describes the cause of this bug