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

email.header.Header.encode() crashes with IndexError on spaces only value #71924

Closed
timgraham mannequin opened this issue Aug 11, 2016 · 4 comments
Closed

email.header.Header.encode() crashes with IndexError on spaces only value #71924

timgraham mannequin opened this issue Aug 11, 2016 · 4 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@timgraham
Copy link
Mannequin

timgraham mannequin commented Aug 11, 2016

BPO 27737
Nosy @warsaw, @bitdancer, @timgraham
PRs
  • bpo-27737: Allow whitespace only headers encoding #13478
  • [3.7] bpo-27737: Allow whitespace only headers encoding (GH-13478) #13517
  • Files
  • whitespace-header-test.diff: regression test for cpython's test suite
  • 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 2019-05-23.01:17:21.594>
    created_at = <Date 2016-08-11.13:51:04.796>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'email.header.Header.encode() crashes with IndexError on spaces only value'
    updated_at = <Date 2019-05-23.01:41:47.667>
    user = 'https://github.com/timgraham'

    bugs.python.org fields:

    activity = <Date 2019-05-23.01:41:47.667>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-23.01:17:21.594>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2016-08-11.13:51:04.796>
    creator = 'Tim.Graham'
    dependencies = []
    files = ['44077']
    hgrepos = []
    issue_num = 27737
    keywords = ['patch']
    message_count = 4.0
    messages = ['272447', '343262', '343264', '343269']
    nosy_count = 3.0
    nosy_names = ['barry', 'r.david.murray', 'Tim.Graham']
    pr_nums = ['13478', '13517']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27737'
    versions = ['Python 3.7', 'Python 3.8']

    @timgraham
    Copy link
    Mannequin Author

    timgraham mannequin commented Aug 11, 2016

    Python 2.7:
    >>> from email.header import Header
    >>> Header(' ').encode()
    ''
    
    Python 3.2+ (I didn't check older versions of Python 3):
    >>> Header(' ').encode()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/tim/code/cpython/Lib/email/header.py", line 391, in encode
        value = formatter._str(linesep)
      File "/home/tim/code/cpython/Lib/email/header.py", line 427, in _str
        self.newline()
      File "/home/tim/code/cpython/Lib/email/header.py", line 439, in newline
        self._lines[-1] += str(self._current_line)
    IndexError: list index out of range

    (Originally reported at https://code.djangoproject.com/ticket/27051)

    @timgraham timgraham mannequin added the stdlib Python modules in the Lib dir label Aug 11, 2016
    @SilentGhost SilentGhost mannequin added the type-bug An unexpected behavior, bug, or error label Aug 11, 2016
    @bitdancer
    Copy link
    Member

    New changeset ef5bb25 by R. David Murray (Batuhan Taşkaya) in branch 'master':
    bpo-27737: Allow whitespace only headers encoding (bpo-13478)
    ef5bb25

    @bitdancer
    Copy link
    Member

    Thanks.

    @bitdancer bitdancer added 3.7 (EOL) end of life 3.8 only security fixes labels May 23, 2019
    @bitdancer
    Copy link
    Member

    New changeset 0416d6f by R. David Murray (Miss Islington (bot)) in branch '3.7':
    bpo-27737: Allow whitespace only headers encoding (GH-13478) (bpo-13517)
    0416d6f

    @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
    3.7 (EOL) end of life 3.8 only security fixes 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