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
net/http: ParseMultipartForm does not return ErrNotMultipart #6334
Labels
Milestone
Comments
Failure on linux/amd64 with gc: 2013/09/09 22:56:13 net/http: invalid Cookie.Domain "wrong;bad.abc"; dropping domain attribute 2013/09/09 22:56:13 net/http: invalid Cookie.Domain "bad-.abc"; dropping domain attribute 2013/09/09 22:56:13 net/http: invalid Cookie.Domain "::1"; dropping domain attribute 2013/09/09 22:56:13 net/http: invalid byte ' ' in Cookie.Value; dropping invalid bytes 2013/09/09 22:56:13 net/http: invalid byte '\x00' in Cookie.Value; dropping invalid bytes 2013/09/09 22:56:13 net/http: invalid byte '"' in Cookie.Value; dropping invalid bytes 2013/09/09 22:56:13 net/http: invalid byte ';' in Cookie.Path; dropping invalid bytes --- FAIL: TestEmptyMultipartRequest (0.00 seconds) request_test.go:341: FormFile err = "request Content-Type isn't multipart/form-data", want ErrMissingFile FAIL FAIL net/http 3.570s |
I took a closer look at this. With a simple server (attached), it's possible to call ParseMultipartForm() and receive no error, and for Request.MultipartForm to be nil. Request which results in parsed form/no error: curl -X POST -H 'Content-Type:multipart/form-data' -F file=mime.txt 'http://localhost:9001/upload' Request which doesn't return an error/doesn't result in a value for Request.MultipartForm: curl -X POST -H 'Content-Type:multipart/bad' -F file=mime.txt 'http://localhost:9001/upload' The line in ParseMultipartForm which returns nil (http://golang.org/src/pkg/net/http/request.go#L783) comes after a call to ParseForm which has a TODO (http://golang.org/src/pkg/net/http/request.go#L704) for handling multipart/form-data. So I'm guessing it was intended to be cleaned up. An easy workaround is just to check the Content-Type before calling ParseMultipartForm. Happy to submit a CL with fix and test (when the tree opens) if that's a good idea. Attachments:
|
https://golang.org/cl/44040043 The server in main.go (attached above) now returns ErrNotMultipart instead of nil. |
CL https://golang.org/cl/44040043 references this issue. |
This issue was closed by revision 8d1b63a. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by Adrian.Migraso:
The text was updated successfully, but these errors were encountered: