parse_mimetype: skip whitespace-only segments after a semicolon#13058
Draft
HrachShah wants to merge 2 commits into
Draft
parse_mimetype: skip whitespace-only segments after a semicolon#13058HrachShah wants to merge 2 commits into
HrachShah wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13058 +/- ##
=======================================
Coverage 98.96% 98.96%
=======================================
Files 131 131
Lines 48156 48156
Branches 2499 2499
=======================================
Hits 47656 47656
Misses 376 376
Partials 124 124
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
|
4b9457b to
e8e099b
Compare
e8e099b to
5a2cac2
Compare
5a2cac2 to
5994311
Compare
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.
What do these changes do?
A trailing semicolon followed by whitespace (e.g.
text/html;ortext/html;\t) used to be split into a parameter segment that is truthy but contains only whitespace, andparse_mimetypewould add it to the parsed parameters dict as{'': ''}. The pre-existingif not item: continuecheck only handled the case of a bare trailing;.The fix changes the check to
if not item.strip()so whitespace-only segments are also treated as no-op, matching the RFC 2045 view that there is no parameter — only a delimiter followed by nothing.The pre-existing
application/json; charset=utf-8;test (a real parameter followed by a bare trailing;) still produces{'charset': 'utf-8'}and is unaffected by this change.Are there changes in behavior for the user?
Yes.
parse_mimetypecallers that read parameters via.get('charset')no longer see the spurious empty-key entry{'': ''}fromtext/html;style inputs. The behaviour fortext/html;(a bare trailing semicolon, which was already correctly producing{}) is preserved.Is it a substantial burden for the maintainers to support this?
No. One-line change in
parse_mimetype. No public API changes.Related issue number
Fixes #13009
Checklist
Drafted with Zo Bot; reviewed by HrachShah.
Drafted with Zo Bot; reviewed by HrachShah.