Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imaplib status command cannot handle folder name containing whitespaces #67866

Closed
bjshan mannequin opened this issue Mar 16, 2015 · 2 comments
Closed

imaplib status command cannot handle folder name containing whitespaces #67866

bjshan mannequin opened this issue Mar 16, 2015 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@bjshan
Copy link
Mannequin

bjshan mannequin commented Mar 16, 2015

BPO 23678
Nosy @bitdancer
Superseder
  • bpo-917120: imaplib: incorrect quoting in commands
  • 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 = <Date 2015-03-16.15:16:36.522>
    created_at = <Date 2015-03-16.09:31:53.567>
    labels = ['type-bug', 'library']
    title = 'imaplib status command cannot handle folder name containing whitespaces'
    updated_at = <Date 2015-03-16.15:16:36.520>
    user = 'https://bugs.python.org/bjshan'

    bugs.python.org fields:

    activity = <Date 2015-03-16.15:16:36.520>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-16.15:16:36.522>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2015-03-16.09:31:53.567>
    creator = 'bjshan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23678
    keywords = []
    message_count = 2.0
    messages = ['238188', '238210']
    nosy_count = 2.0
    nosy_names = ['r.david.murray', 'bjshan']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '917120'
    type = 'behavior'
    url = 'https://bugs.python.org/issue23678'
    versions = ['Python 3.4']

    @bjshan
    Copy link
    Mannequin Author

    bjshan mannequin commented Mar 16, 2015

    imaplib status failed if the folder name contains whitespace.
    For example,
    c = IMAP4_SSL('hostname')
    c = login(username, password)
    c.status('Drafts', '(MESSAGES)') # would succeed
    c.status('Apple Mail To Do', '(MESSAGES)') # would fail, error message is:
    imaplib.error: STATUS command error: BAD [b"parse error: wrong character; expected '(' but got 'M'"]

    It seems the status method could not properly parse the folder name "Apple Mail To Do", it recognizes only the first word "Apple", then failed when meeting the following word "Mail".

    I checked imaplib.py, _command 's definition looks like the cause, but I am not sure:

        def _command(self, name, *args):
             
            ...    
            
            name = bytes(name, 'ASCII')
            data = tag + b' ' + name
            for arg in args:
                if arg is None: continue
                if isinstance(arg, str):
                    arg = bytes(arg, "ASCII")
                data = data + b' ' + arg

    Work around for this:
    Manually add double quote around the folder name, like:
    '"' + mailbox_name + '"'

    BUT,
    while c.status('"Apple Mail To Do"', '(MESSAGES)') worked,
    c.status("'Apple Mail To Do'", '(MESSAGES)') failed. Suggesting single and double quote weighs not the same?

    @bjshan bjshan mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 16, 2015
    @bitdancer
    Copy link
    Member

    This is a duplicate of a subset of bpo-917120.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant