golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.58k stars 17.48k forks source link

mime: glob pattern is not expanded #52609

Open zhsj opened 2 years ago

zhsj commented 2 years ago

What version of Go are you using (go version)?

$ go version
go version go1.18.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zhsj/.cache/go-build"
GOENV="/home/zhsj/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zhsj/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zhsj/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/t/t/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build341454139=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
        "fmt"
        "mime"
)

func main() {
        exts, _ := mime.ExtensionsByType("video/x-anim")
        fmt.Println(exts)
        typ := mime.TypeByExtension(".anim1")
        fmt.Println(typ)
}

What did you expect to see?

.anim1 .anim2 .anim3 .anim4 .anim5 .anim6 .anim7 .anim8 .anim9 .animj
video/x-anim

What did you see instead?

[.anim[1-9j]]

/usr/share/mime/globs2 has 50:video/x-anim:*.anim[1-9j].

ianlancetaylor commented 2 years ago

CC @Jacalz

Jacalz commented 2 years ago

CC @Jacalz

I guess this makes sense, but I don’t think I’ll be able to look at this any time soon though. I’m quite busy with university studies at the moment.

kkHAIKE commented 2 years ago

but this case was skiped recently https://github.com/golang/go/commit/df2421de60215cfc314fe6772ff6c2c6201f7abb

gopherbot commented 2 years ago

Change https://go.dev/cl/418556 mentions this issue: mime: range glob expansions in type_unix.go