mime: ParseMediaType can parse something FormatMediaType can't reformat #56614
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
During fuzzing some custom HTTP request handling of my own I discovered a Content-Type
#;*0=""
whichmime.ParseMediaType
is happy to parse more or less as I would expect without error, but for whichmime.FormatMediaType
returns an empty string indicating some part of it is invalid.I'm not familiar enough with the details of the relevant standards to say which of the two is correct - I seriously doubt anyone needs it to be valid - but these two functions should probably agree on whether it's valid or not.
It seems possibly related to, but the impact is distinct from, #43128.
What version of Go are you using (
go version
)?But also reproducible on go.dev.
What did you do?
https://go.dev/play/p/oeqtYtq72MY
What did you expect to see?
An error during parsing, or some non-empty equivalent media type when reformatted:
What did you see instead?
The text was updated successfully, but these errors were encountered: