这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions textproto/multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,14 @@ func (r *MultipartReader) NextPart() (*Part, error) {
return bp, nil
}

if r.isFinalBoundary(line) {
// Only return EOF if we've reached the final boundary that we are looking for, and are not expecting any
// further parts to the multipart encoding. This prevents the parser from stopping too soon during nested
// multipart boundaries https://www.rfc-editor.org/rfc/rfc2046#section-5.1
if r.isFinalBoundary(line) && !expectNewPart {
// Expected EOF
return nil, io.EOF
}

if expectNewPart {
return nil, fmt.Errorf("multipart: expecting a new Part; got line %q", string(line))
}

if r.partsRead == 0 {
// skip line
continue
Expand All @@ -295,6 +294,10 @@ func (r *MultipartReader) NextPart() (*Part, error) {
continue
}

if expectNewPart {
continue
}

return nil, fmt.Errorf("multipart: unexpected line in Next(): %q", line)
}
}
Expand Down