diff options
| author | Shulhan <m.shulhan@gmail.com> | 2023-05-11 15:23:39 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2023-05-11 16:16:12 +0700 |
| commit | 9d1afbf308f2ac382f364f935867ce0cef0a3573 (patch) | |
| tree | f4e3818d1b44329dea9a5a7f4a8021f0edeb087d /src/mime/multipart/multipart.go | |
| parent | a2838ec5f20b56e94a18c873ab4b68397355e214 (diff) | |
| download | go-ms-fix-multipart-readform.tar.xz | |
mime/multipart: fix ReadForm always return (nil,io.EOF)ms-fix-multipart-readform
Previously, the condition err == io.EOF in readForm will never true and
break; it always goes to the second condition, err != nil, which
cause the returned ReadForm always nil with err is io.EOF.
As the test, we use the example with body almost similar to
ExampleNewReader with header contains "Content-Disposition:form-data".
Change-Id: I7268f45bb26eafb7f1e6e471b86eec681dde99f7
Diffstat (limited to 'src/mime/multipart/multipart.go')
| -rw-r--r-- | src/mime/multipart/multipart.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mime/multipart/multipart.go b/src/mime/multipart/multipart.go index da1f45810e..c570f1d7e2 100644 --- a/src/mime/multipart/multipart.go +++ b/src/mime/multipart/multipart.go @@ -30,6 +30,7 @@ package multipart import ( "bufio" "bytes" + "errors" "fmt" "internal/godebug" "io" @@ -392,7 +393,7 @@ func (r *Reader) nextPart(rawPart bool, maxMIMEHeaderSize, maxMIMEHeaders int64) for { line, err := r.bufReader.ReadSlice('\n') - if err == io.EOF && r.isFinalBoundary(line) { + if errors.Is(err, io.EOF) && r.isFinalBoundary(line) { // If the buffer ends in "--boundary--" without the // trailing "\r\n", ReadSlice will return an error // (since it's missing the '\n'), but this is a valid |
