-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by magius.varios:
What steps will reproduce the problem? 1.I send an email from my gmail account to an app at AppEngineGo 2. It's receive a multipart email (Content-Type: multipart/alternative) with 2 parts: "Content-Type: text/plain", "Content-Type: text/html" 3. I try to read the differents parts with "mime/multipart" rmp := multipart.NewReader(tp.R, boundary); part,_ := rmp.NextPart() What is the expected output? 2 Part object (in 2 calls to rmp.NextPart()) What do you see instead? It returns only one Part object with both parts inside (the second as text, it didn't detected the boundary mark) Which compiler are you using (5g, 6g, 8g, gccgo)? 8g Which operating system are you using? linux 386 Which revision are you using? (hg identify) r57 Please provide any additional information below. NextPart calls to Read, which read until detect the part boundary. It expects to find <"\r\n--" + boundary> but gmail sends only <"\n--" + boundary> As a sugestion, it works for me (and pass the tests) to change/add some lines in the file "multipart.go" (marked with +++) func (bp *Part) Read(p []byte) (n int, err os.Error) { ... // Search the peek buffer for "\r\n--boundary". If found, // consume everything up to the boundary. If not, consume only // as much of the peek buffer as cannot hold the boundary // string. nCopy := 0 foundBoundary := false +++ if idx := bytes.Index(peek, bp.mr.nlDashBoundary[1:]); idx != -1 { +++ if idx > 0 && peek[idx-1] == '\r' { +++ idx-- +++ } nCopy = idx foundBoundary = true } else if safeCount := len(peek) - len(bp.mr.nlDashBoundary); safeCount > 0 { nCopy = safeCount } else if unexpectedEof { // If we've run out of peek buffer and the boundary // wasn't found (and can't possibly fit), we must have // hit the end of the file unexpectedly. return 0, io.ErrUnexpectedEOF } ...