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: we don't decode quoted-printable #4411

Closed
bradfitz opened this issue Nov 19, 2012 · 8 comments
Closed

mime: we don't decode quoted-printable #4411

bradfitz opened this issue Nov 19, 2012 · 8 comments
Assignees
Milestone

Comments

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Nov 19, 2012

App Engine has a current production bug where long text values (non-file parts) of blob
uploads are sent from Google's MIME encoder to the user's HTTP handler, with the MIME
bodies re-encoded as quoted-printable.

Go's mime/multipart package does not decode quoted-printable.

Demo: http://bradgaetest.appspot.com/

The bytes sent to the handler are:

"--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain;
charset=ISO-8859-1\r\nContent-Disposition: form-data;
name=text\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nwords words words words
words words words words words words words words wor=\r\nds words words words words words
words words words words words words words =\r\nwords words words words words words words
words words words words words wor=\r\nds words words words words words words words words
words words words words =\r\nwords words words words words words words words
words\r\n--0016e68ee29c5d515f04cedf6733\r\nContent-Type: text/plain;
charset=ISO-8859-1\r\nContent-Disposition: form-data;
name=submit\r\n\r\nSubmit\r\n--0016e68ee29c5d515f04cedf6733--"

That was captured with:

        var buf bytes.Buffer
        r.Body = ioutil.NopCloser(io.TeeReader(r.Body, &buf))
    _, other, err := blobstore.ParseUpload(r)

I propose adding a non-exported quotedPrintableReader to the multipart package for now,
so this could be cherry-picked into production, but perhaps later we should move the
reader type to the mime (not multipart) package, and then just use that reader from the
multipart package (it already depends on the mime package, so it wouldn't be a new
dependency).
@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Nov 19, 2012

Comment 1:

Labels changed: added appengine.

Loading

@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Nov 20, 2012

Comment 2:

This issue was closed by revision d32d1e0.

Status changed to Fixed.

Loading

@wathiede
Copy link
Member

@wathiede wathiede commented Nov 20, 2012

Comment 3:

Is there a reason you wouldn't implement quoted-printable as a package under encoding
and let the user do the decoding, much like you would with base64 encoded data in a
multipart mime message? Alternatively do you foresee multipart.newPart growing the
ability to transparently decode more types?

Loading

@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Nov 20, 2012

Comment 4:

Yeah, as I mentioned in comment 0, we might want to move this to a general place later.
I don't know whether we should expand this to handle more encodings.  I felt like this
one was special enough, though.  It broke common cases, preventing things like
http://golang.org/pkg/net/http/#Request.FormValue from working.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 5, 2013

Comment 5 by runningmaster:

When I tryed to get HTML from MHT file (MIME HTML) I lost (in HTML code) all line
endings and spaces in the text (all words are joined).
Concept:
    mht, err := os.Open("example.mht")
    panicIfError(err)
    msg, err := mail.ReadMessage(mht)
    panicIfError(err)
    _, prm, err := mime.ParseMediaType(msg.Header.Get("Content-Type"))
    panicIfError(err)
    bnd := prm["boundary"]
    rdr := multipart.NewReader(msg.Body, bnd)
    prt, err := rdr.NextPart()
    panicIfError(err)
    buf := &bytes.Buffer{}
    io.Copy(buf, prt)
    err = ioutil.WriteFile("x.html", buf.Bytes(), os.ModePerm)
    panicIfError(err)

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 6, 2013

Comment 6 by runningmaster:

My trouble with extract HTML part from MIME HTML file.
Please see for details:
http://play.golang.org/p/CPJFI_qMM4

Loading

@bradfitz
Copy link
Contributor Author

@bradfitz bradfitz commented Feb 6, 2013

Comment 7:

This bug is closed and marked Fixed.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 7, 2013

Comment 8 by runningmaster:

OK, https://golang.org/issue/4771

Loading

@bradfitz bradfitz self-assigned this Feb 7, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants