Open
Description
Bug report
Bug description:
The below code exits with a TypeError exception when provided with malformed input. This type error occurs in python3.12/email/utils.py
at line 286. The error message is this: TypeError: '<' not supported between instances of 'int' and 'NoneType'
import sys
from email.message import Message
m = Message()
buf = open(sys.argv[1], "r").read()
m['content-type'] = buf
dict(m.get_params())
POC File
https://github.com/FuturesLab/POC/blob/main/py-email/poc-01
How to trigger
python filename.py poc-01
Execution Trace
Traceback (most recent call last):
File "rep.py", line 7, in <module>
dict(m.get_params())
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 691, in get_params
params = self._get_params_preserve(missing, header)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 674, in _get_params_preserve
params = utils.decode_params(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/utils.py", line 286, in decode_params
continuations.sort()
TypeError: '<' not supported between instances of 'int' and 'NoneType'
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
only security fixesonly security fixesbugs and security fixesbugs and security fixesbugs and security fixesbugs and security fixesPython modules in the Lib dirPython modules in the Lib dirAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error