Bug report
Bug description:
With policy.default a parameter value containing an unquoted apostrophe is not returned, while compat32 returns it. The apostrophe is not a tspecial (RFC 2045), so a bare value such as filename=O'Brien.pdf is a valid token and should be parsed whole.
import email, email.policy
msg = email.message_from_string(
"Content-Disposition: attachment; filename=O'Brien.pdf\n\nbody\n",
policy=email.policy.default
)
msg.get_filename() is None
True
Under email.policy.compat32 the same string returns "O'Brien.pdf". Quoting the value (filename="O'Brien.pdf") works under both policies.
For a multipart message an unquoted apostrophe in the boundary is not recognized, so is_multipart() returns False and the message is not split.
ASPECIALS in Lib/email/_header_value_parser.py includes "'" unconditionally, which terminates the value.
Observed on 3.16.0a0.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
With
policy.defaulta parameter value containing an unquoted apostrophe is not returned, whilecompat32returns it. The apostrophe is not a tspecial (RFC 2045), so a bare value such asfilename=O'Brien.pdfis a valid token and should be parsed whole.Under
email.policy.compat32the same string returns"O'Brien.pdf". Quoting the value (filename="O'Brien.pdf") works under both policies.For a multipart message an unquoted apostrophe in the boundary is not recognized, so
is_multipart()returnsFalseand the message is not split.ASPECIALSinLib/email/_header_value_parser.pyincludes"'"unconditionally, which terminates the value.Observed on
3.16.0a0.CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs