Skip to content

gh-130110: Support hyphens in RFC 2231 continuation parameter names#153536

Open
Phantom-d-e-v wants to merge 3 commits into
python:mainfrom
Phantom-d-e-v:gh-130110-email-hyphen-param
Open

gh-130110: Support hyphens in RFC 2231 continuation parameter names#153536
Phantom-d-e-v wants to merge 3 commits into
python:mainfrom
Phantom-d-e-v:gh-130110-email-hyphen-param

Conversation

@Phantom-d-e-v

Copy link
Copy Markdown

Parameter names containing hyphens (e.g. file-name*0*) were not recognized as RFC 2231 continuations because the matching regular expression only allowed \w+. As a result, such parameters were left undecoded by email.utils.decode_params.

Adjust the regular expression to also accept hyphens ([\w-]+), which matches the production behaviour for non-hyphenated names.

Fixes: gh-130110

…ames

Parameter names containing hyphens (e.g. `file-name*0*`) were not
recognized as RFC 2231 continuations because the matching regular
expression only allowed `\w+`. As a result, such parameters were left
undecoded by `email.utils.decode_params`.

Adjust the regular expression to also accept hyphens (`[\w-]+`), which
matches the production behaviour for non-hyphenated names.

Fixes: pythongh-130110
@Phantom-d-e-v Phantom-d-e-v requested a review from a team as a code owner July 10, 2026 23:27
@bedevere-app

bedevere-app Bot commented Jul 10, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Lib/email/utils.py


rfc2231_continuation = re.compile(r'^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$',
rfc2231_continuation = re.compile(r'^(?P<name>[\w-]+)\*((?P<num>[0-9]+)\*?)?$',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to go to the trouble of fixing this, we should make it conform fully to the RFC. Are there any printable characters other than - that are not in specials and also not in \w? Hopefully there aren't any characters recognized by \w that shouldn't be valid in parameter names, because changing that would be backward incompatible.

@bedevere-app

bedevere-app Bot commented Jul 11, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

email.utils.decode_params not supporting params that contain hyphens

2 participants