Bug report
Bug description:
Documented behaviour: RFC 2231 §3 states: "The matching of attributes MUST be case-insensitive." ParameterizedMIMEHeader implements the documented MIME parameter mapping, and its source explicitly normalizes parameter names with .lower().
Expected: header.params['filename'] == 'report.txt'
Actual: header.params['filename'] == '.txt'
import email.headerregistry as hr
import re
from urllib.parse import unquote_to_bytes
s = "attachment; filename*0*=us-ascii''report; FILENAME*1*=.txt"
# Valid RFC 2231: case-insensitive attributes, consecutive segments,
# declared ASCII charset, empty language, and token-safe ASCII values.
m = re.fullmatch(
r"attachment; filename\*0\*=us-ascii''([A-Za-z]+); filename\*1\*=([A-Za-z.]+)",
s, re.I | re.ASCII,
)
if not m:
print("REFUTATION REJECTED: input fails independent validity check")
else:
expected = b"".join(unquote_to_bytes(v) for v in m.groups()).decode("ascii")
actual = hr.HeaderRegistry()("Content-Disposition", s).params.get("filename")
if actual != expected:
print(f"REFUTATION CONFIRMED: {s!r} actual={actual!r} expected={expected!r}")
else:
print("REFUTATION REJECTED: actual matches documented expectation")
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library email.headerregistry:
REFUTATION CONFIRMED: "attachment; filename*0*=us-ascii''report; FILENAME*1*=.txt" actual='.txt' expected='report.txt'
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/email.headerregistry-20261003-195236-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: RFC 2231 §3 states: "The matching of attributes MUST be case-insensitive." ParameterizedMIMEHeader implements the documented MIME parameter mapping, and its source explicitly normalizes parameter names with .lower().
Expected: header.params['filename'] == 'report.txt'
Actual: header.params['filename'] == '.txt'
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
email.headerregistry:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/email.headerregistry-20261003-195236-c3
CPython versions tested on:
3.14
Operating systems tested on:
Windows