Skip to content
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/multipart: add (*Reader).NextRawPart to bypass automatic quoted-printable handling #29090

Closed
buchanae opened this issue Dec 4, 2018 · 5 comments
Labels
FeatureRequest FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@buchanae
Copy link
Contributor

buchanae commented Dec 4, 2018

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

$ go version
go version go1.11.1 darwin/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="/Users/abuchanan/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/abuchanan/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/abuchanan/projects/mailer/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r8/1_92bxy977zcfcj2jpp5j2dc0000gn/T/go-build702584477=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://play.golang.org/p/7x85EhvIbZZ

What did you expect to see?

I expected the part headers to include the Content-Transfer-Encoding as-is, and for the part body reader to return content as-is.

What did you see instead?

I found that Part has special handling for parts with Content-Transfer-Encoding: quoted-printable, which as introduced in issue #4411.

GitHub has also just led me to issue #26803 (which I failed to find before) which also proposes a way to bypass this via Part.NextRawPart. Unfortunately, although that proposal was accepted, the issue was closed by the submitter before being implemented.

Having access to the raw part body and unmodified headers is useful. In particular, for an IMAP server, I need to be able to inspect the part headers and body, including the Content-Transfer-Encoding header, in order to build the BODYSTRUCTURE response.

I can think of a couple workarounds for my particular server but they're not great, and I think this deserves a fix in the std library.

@buchanae buchanae changed the title mime/multipart: allow disabling automatic quoted-printable handling mime/multipart: add (*Reader).NextRawPart to bypass automatic quoted-printable handling Dec 4, 2018
@buchanae
Copy link
Contributor Author

buchanae commented Dec 4, 2018

To be clear, the signature would be func (r *Reader) NextRawPart() (*Part, error) and it would still decode the headers for you, it just wouldn't decode the body nor check the encoding header.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 5, 2018

Still SGTM.

@bradfitz bradfitz added help wanted NeedsFix The path to resolution is known, but the work has not been done. FeatureRequest labels Dec 5, 2018
@bradfitz bradfitz added this to the Go1.13 milestone Dec 5, 2018
@gopherbot
Copy link

Change https://golang.org/cl/152877 mentions this issue: mime/multipart: add Part.NextRawPart() to avoid QP decoding

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@abuchanan-nr
Copy link

As far as I can tell, this is ready to go still. The issue has the labels "help wanted" and "needs fix". Might want to double check whether those are still valid.

Would love to take this off my todo list.

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@smasher164 smasher164 modified the milestones: Backlog, Go1.14 Oct 11, 2019
@gopherbot
Copy link

Change https://golang.org/cl/217128 mentions this issue: doc/go1.14: mention new method mime/multipart.(*Reader).NextRawPart

gopherbot pushed a commit that referenced this issue Jan 31, 2020
Updates #29090
Updates #36878

Change-Id: I63f0eb583285d5c12f591cb704097cdf6a67b64f
Reviewed-on: https://go-review.googlesource.com/c/go/+/217128
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Jan 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants