Skip to content

mime: avoid panicking when reading globs2 files #82033

Open

Description

@cuishuang

Go version

go version go1.28-devel

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/mac/go/bin'
GOCACHE='/Users/mac/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/mac/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tq/m955dwkd1519phkp2hwpv9_80000gn/T/go-build1415656419=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/mac/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPACKAGESDRIVER=''
GOPATH='/Users/mac/go'
GOPRIVATE=''
GOPROXY=''
GOROOT='/Users/mac/202609/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/mac/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/mac/202609/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.28-devel_d758038bdf Tue Aug 11 10:10:28 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

On Unix, read a MIME globs2 database containing a line longer than bufio.Scanner's maximum token size, for example by triggering MIME initialization with such a database installed at a configured globs2 path.

What did you see happen?

mime.loadMimeGlobsFile panics when bufio.Scanner encounters the overlong line. The panic prevents initialization from trying the next MIME database or falling back to mime.types.

What did you expect to see?

loadMimeGlobsFile returns the scanner error, allowing initialization to continue to the next database or fallback.

Activity

  1. cuishuang commented on Oct 6, 2026

    @cuishuang
    ContributorAuthor
  2. gopherbot commented on Oct 6, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/845705 mentions this issue: mime: return scanner errors from globs2 files

  3. dmitshur commented on Oct 6, 2026

    @dmitshur
    Member

    CC @neild.

  4. added this to the Go1.28 milestone on Oct 6, 2026
  5. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.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