golang / go

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

mime/multipart: quoted-printable check is case sensitive #28674

Closed laochailan closed 5 years ago

laochailan commented 5 years ago

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

$ go version
go version go1.11.2 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build092395101=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I use Part.Read() to read from a multipart body containing parts that have Content-Transfer-Encoding: Quoted-printable with non-lowercase quoted-printable.

https://play.golang.org/p/G_4Dq4YEo4_4

What did you expect to see?

The correctly decoded letter ü. RFC 2045 6.1 states that this header field is case insensitive and as always with e-mail, apart from the RFC only creativity is the limit. I got QUOTED-PRINTABLE and Quoted-Printable so far…

What did you see instead?

The raw =C3=BC.

In src/mime/multipart/multipart.go:138 the check appears to assume lower case transfer encoding.

gopherbot commented 5 years ago

Change https://golang.org/cl/148579 mentions this issue: mime/multipart: check for quoted-printable case insensitively