adding a charset parameter to the mime-type header can cause the breakage to take different forms.
which is strange because charset is only defined for text/* content (not for multipart/*) and the offending
content is not MIME content anyway, it is preamble content.
removing the Mime-Type: header prevents this bug from manifesting,
The following monkey-patch prevents the exception, but the result is still wrong in different ways depending on the setting of charset (which should in theory have no effect)
A clear and concise description of the bug
email.message_from_bytes in some circumstances is not reversible by email::as_bytes
eg:
adding a charset parameter to the mime-type header can cause the breakage to take different forms. which is strange because charset is only defined for
text/*
content (not formultipart/*
) and the offending content is not MIME content anyway, it is preamble content.removing the
Mime-Type:
header prevents this bug from manifesting,The following monkey-patch prevents the exception, but the result is still wrong in different ways depending on the setting of charset (which should in theory have no effect)
This suggests to me that email.parser is doing something wrong.
Your environment
Debian linux version 10 to 12, AMD64 python 3.7 to 3.11.2