-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mime: ParseMediaType should not return an error if mediatype is empty #69551
Comments
cc @neild |
What should |
@ianlancetaylor it's hard for me to tell from the spec, but I believe that would be invalid and should throw. The chromium parsing code starts here, for reference: https://github.com/chromium/chromium/blob/main/net/http/http_content_disposition.cc#L397 They appear to treat the disposition type and filename parsing separately. And the only completely invalid header is when there is no disposition type or filename |
If we follow the logic in https://github.com/chromium/chromium/blob/04b3bd7342eb7ca8f114c7a5c5e466d802f9522b/net/http/http_content_disposition.cc#L350-L377, maybe we should set it to |
Go version
go version 1.23.0
Output of
go env
in your module/workspace:What did you do?
I have a file server that returns
Content-Disposition
headers like this:;filename*=UTF-8''hello-world.pdf
Example: https://go.dev/play/p/rxRNVZGDOQu
What did you see happen?
mime.ParseMediaType
fails with the error "mime: no media type" (from here in code)What did you expect to see?
mime.ParseMediaType
succeeds, returning mediatype""
andparams["filename"]
hello-world.pdf
Unknown or unhandled disposition types SHOULD be handled by recipients the same way as "attachment"
, and presumably an empty string disposition type fits into thatThe text was updated successfully, but these errors were encountered: