Skip to content

The as_bytes method of an email message can fold headers improperly. #114362

@msapiro

Description

@msapiro

Bug report

Bug description:

This code

import email
msg = email.message_from_bytes(b"""To: [email protected]
From: "Txxxxxx Mxxxxxxx de Vxxxxxx, Fxxxxxxxx" <[email protected]>

body
""")

creates a message object which when flattened as bytes erroneously folds the long From: header following the comma inside the quoted string.

msg.as_bytes()
b'To: [email protected]\nFrom: "Txxxxxx Mxxxxxxx de Vxxxxxx,\n Fxxxxxxxx" <[email protected]>\n\nbody\n'

CPython versions tested on:

3.9, 3.11

Operating systems tested on:

Linux

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