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: Handling when both extended/ascii parameter (filename*/filename) are present?
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: The Compiler
Priority: normal Keywords:

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

Messages (1)
msg385163 - (view) Author: Florian Bruhin (The Compiler) * Date: 2021-01-17 17:28
Consider this reproducer:

    >>> import email.headerregistry
    >>> reg = email.headerregistry.HeaderRegistry()
    >>> parsed = reg('Content-Disposition', """attachment; filename="foo-ae.html"; filename*=UTF-8''foo-%c3%a4.html""")
    >>> parsed.defects
    (InvalidHeaderDefect('duplicate parameter name; duplicate(s) ignored'),)
    >>> parsed.params['filename']

However, the relevant section of RFC 5987 says:

> This specification suggests that a parameter using the extended syntax takes precedence. This would allow producers to use both formats without breaking recipients that do not understand the extended syntax yet.

And RFC 6266 says:

> Many user agent implementations predating this specification do not understand the "filename*" parameter. Therefore, when both "filename" and "filename*" are present in a single header field value, recipients should pick "filename*" and ignore "filename". This way, senders can avoid special-casing specific user agents by sending both the more expressive "filename*" parameter, and the "filename" parameter as fallback for legacy recipients (see Section 5 for an example).

Also see the related attfnboth and attfnboth2 test cases here:

I'm aware those two RFCs are specific to HTTP - but given that there's a "HTTP" policy and "" has some HTTP-specific date/time handling, I suppose correct handling of this might be in scope as well?
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87113
2021-01-17 17:28:07The Compilercreate