Ignore RFC 2231 extended parameters in parse_options_header#291
Merged
Conversation
Replace `email.message.Message` with a small vendored `_parseparam` splitter and ignore the RFC 5987/2231 extended syntax (`name*`, `filename*`, and their continuations), keeping the plain parameter authoritative per RFC 7578 §4.2.
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.
parse_options_headerparsed Content-Type/Content-Disposition headers withemail.message.Message, which transparently applies RFC 2231/5987 decoding: afilename*=utf-8''valueparameter is percent-decoded and surfaced under the barefilenamekey,name*likewise, andfilename*0/filename*1continuations are reassembled. RFC 7578 §4.2 states this extended syntax MUST NOT be used inmultipart/form-data.This replaces
email.message.Messagewith a small vendored copy of the stdlib'semail.message._parseparamto split the header into its;-separated parts (correctly ignoring;inside quoted strings), and then ignores any*-suffixed parameter. The plainname/filenameis now authoritative, matchingurllib.parse, browsers, and other compliant parsers - none of which emit the extended form.Beyond ignoring the extended parameters, behaviour is unchanged: content-type casing, quoted values, backslash unquoting, the IE6 path fix, and parameter casing all match the previous implementation. Dropping
Messagealso removes the fuzz-driventry/exceptaroundget_params()and its Python 3.12-only special case.AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.