Skip to content

imaplib fails when server sends extra blank line after literal value #88574

Closed

Description

@jrlevine
mannequin
BPO 44408
Nosy @iritkatriel, @jrlevine
PRs
  • gh-88574: Handle extra blank response line in imaplib #26701
  • 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 2021-06-13.05:34:08.636>
    labels = ['type-bug', 'library', '3.9', '3.10']
    title = 'imaplib fails when server sends extra blank line after literal value'
    updated_at = <Date 2022-01-19.19:33:36.808>
    user = 'https://github.com/jrlevine'

    bugs.python.org fields:

    activity = <Date 2022-01-19.19:33:36.808>
    actor = 'jrlevine'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-06-13.05:34:08.636>
    creator = 'jrlevine'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44408
    keywords = ['patch']
    message_count = 3.0
    messages = ['395729', '410655', '410976']
    nosy_count = 2.0
    nosy_names = ['iritkatriel', 'jrlevine']
    pr_nums = ['26701']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44408'
    versions = ['Python 3.9', 'Python 3.10']

    Linked PRs

    Activity

    1. jrlevine commented on Jun 13, 2021

      jrlevinemannequin
      MannequinAuthor

      Some IMAP servers return an extra blank line after a counted literal value, which makes imaplib crash.
      MacOS mail and T'bird handle the blank line OK so it seems to be a somewhat common bug.

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 13, 2021
    3. iritkatriel commented on Jan 15, 2022

      @iritkatriel
      Member

      How does it fail? Can you provide a reproducer and add a unit test to the PR?

    4. 10 remaining items

    5. added 4 commits that reference this issue on Jul 2, 2026
    6. serhiy-storchaka commented on Jul 2, 2026

      @serhiy-storchaka
      Member

      Fixed in #152751: imaplib now skips a spurious blank line sent after a literal, so servers that emit one no longer cause a crash.

    7. added 2 commits that reference this issue on Jul 8, 2026
    8. serhiy-storchaka commented on Jul 8, 2026

      @serhiy-storchaka
      Member

      #152751 skips the spurious blank line unconditionally, but that also swallows the legitimately empty trailer of a response that ends with a literal (e.g. a LIST/LSUB mailbox name sent as a literal), corrupting the next line.

      PR #153317 makes the skip conditional — only while the response is still open — and handles the blank between responses too.

    9. added 4 commits that reference this issue on Jul 8, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard 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