Skip to content

imaplib: Mailbox names are not quoted #58148

Description

@joebauer
mannequin
BPO 13940
Nosy @warsaw, @mcepl, @bitdancer, @soltysh, @bearbin
PRs
  • bpo-13940: imaplib: All string arguments are now quoted when necessary. #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:

    assignee = None
    closed_at = None
    created_at = <Date 2012-02-04.12:04:57.445>
    labels = ['3.7', '3.8', 'type-bug', 'library', 'expert-email']
    title = 'imaplib: Mailbox names are not quoted'
    updated_at = <Date 2018-04-21.08:57:32.272>
    user = 'https://bugs.python.org/joebauer'

    bugs.python.org fields:

    activity = <Date 2018-04-21.08:57:32.272>
    actor = 'mcepl'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'email']
    creation = <Date 2012-02-04.12:04:57.445>
    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']

    Activity

    1. joebauer commented on Feb 4, 2012

      joebauermannequin
      MannequinAuthor

      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

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Feb 4, 2012
    3. BreamoreBoy commented on Jul 3, 2014

      BreamoreBoymannequin
      Mannequin

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

      @david is this within your remit?

    4. bitdancer commented on Jul 3, 2014

      @bitdancer
      Member

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

    5. soltysh commented on Apr 15, 2015

      @soltysh

      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.

    6. soltysh commented on Nov 9, 2015

      @soltysh

      Currently working on a patch for this.

    7. soltysh commented on Nov 13, 2015

      @soltysh

      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

    8. soltysh commented on Dec 8, 2015

      @soltysh

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

    9. bearbin commented on Apr 8, 2018

      bearbinmannequin
      Mannequin

      Pull Request opened on GH to fix this issue: #6395

    10. transferred this issue fromon Apr 10, 2022
    11. vadmium commented on Apr 18, 2024

      @vadmium
      Member

      Issue #92835 describes the cause of this bug

    12. serhiy-storchaka commented on Jul 5, 2026

      @serhiy-storchaka
      Member

      Argument quoting has been restored in GH-152703. Closing as a duplicate of gh-40038.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    3.7 (EOL)end of life3.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions