This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: email: ValueError in get_section when parsing header with non-ASCII digit
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: The Compiler, barry, maxking, r.david.murray
Priority: normal Keywords:

Created on 2021-01-17 17:14 by The Compiler, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg385162 - (view) Author: Florian Bruhin (The Compiler) * Date: 2021-01-17 17:14
Found mostly by accident:

>>> import email.headerregistry
>>> reg = email.headerregistry.HeaderRegistry()
>>> h = reg('Content-Disposition', 'inline; 0*²')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/email/", line 608, in __call__
    return self[name](name, value)
  File "/usr/lib/python3.10/email/", line 196, in __new__
    cls.parse(value, kwds)
  File "/usr/lib/python3.10/email/", line 452, in parse
    kwds['parse_tree'] = parse_tree = cls.value_parser(value)
  File "/usr/lib/python3.10/email/", line 2705, in parse_content_disposition_header
  File "/usr/lib/python3.10/email/", line 2569, in parse_mime_parameters
    token, value = get_parameter(value)
  File "/usr/lib/python3.10/email/", line 2431, in get_parameter
    token, value = get_section(value)
  File "/usr/lib/python3.10/email/", line 2384, in get_section
    section.number = int(digits)
ValueError: invalid literal for int() with base 10: '²'

This probably happens because:

>>> '²'.isdigit()
>>> int('²')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '²'
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87112
2021-01-17 17:14:51The Compilercreate