Skip to content

mime: ParseMediaType should not return an error if mediatype is empty #69551

@aldenquimby

Description

@aldenquimby

Go version

go version 1.23.0

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/alden/Library/Caches/go-build'
GOENV='/Users/alden/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/alden/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/alden/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.1/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/alden/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/_h/_w_mjtt91s1dws8zlxnnjpzm0000gn/T/go-build1772735711=/tmp/go-build -gno-record-gcc-switches -fno-common'

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 "" and params["filename"] hello-world.pdf
  • Note that all modern browsers and email clients parse a blank mediatype correctly
  • rfc6266 and rfc2183 both say Unknown or unhandled disposition types SHOULD be handled by recipients the same way as "attachment", and presumably an empty string disposition type fits into that

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions