[PR #13010/9e00085c backport][3.14] Fix parse_mimetype producing spurious empty-key parameter for whitespace-only segments after semicolons#13096
Merged
Dreamsorcerer merged 1 commit intoJul 8, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.14 #13096 +/- ##
=======================================
Coverage 98.24% 98.24%
=======================================
Files 135 135
Lines 48824 48824
Branches 2619 2619
=======================================
+ Hits 47966 47967 +1
Misses 678 678
+ Partials 180 179 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a backport of PR #13010 as merged into master (9e00085).
Summary
parse_mimetypeincorrectly adds a spurious{'': ''}parameter entry when a MIME type string has a trailing semicolon followed by whitespace (e.g.'text/html; ').Closes #13009
Root cause
aiohttp/helpers.pysplits on;and skips empty segments with:A bare trailing
;(liketext/html;) produces an empty-string segment, which is correctly skipped. Buttext/html;produces a whitespace-only segment (' ') which is truthy — so it is NOT skipped — and ends up asparams.add('', '').Fix
Reproduction / before
After fix
All four return the expected values with no empty-key parameter.
Testing
Four new parametrize cases added to
tests/test_helpers.py::test_parse_mimetype. All 141 existing tests continue to pass.