Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TypeError in email.message.Message.get_params #125648

Copy link
Copy link
Open
@gabe-sherman

Description

@gabe-sherman
Issue body actions

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

No one assigned

    Labels

    3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.