-
Notifications
You must be signed in to change notification settings - Fork 18k
mime/multipart: Reader returns part that contains boundary string #14085
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
Comments
This was fixed in Go 1.5.2: https://golang.org/doc/devel/release.html#go1.5.minor (or at least, an identical-sounding bug was fixed. If you still see it with Go 1.5.2 or Go 1.5.3, let us know) |
Thanks! I'll retest it w/ go 1.5.3 |
@bradfitz upgrading from 1.5.1 to 1.5.3 didn't change the outcome of the unit test -- the go multipart module still can't correctly parse that particular multipart request. It might be caused by some subtlety about the way the original ObjectiveC-based client is sending the request, because in a second unit test I tried using a go http client to reproduce the issue by sending a By "approximately the same content", I mean:
|
@adg, you have time to look at this? You'll be working a bit before me, otherwise I can look (my) Monday. |
@bradfitz @adg I managed to reproduce it via the go http client in a third unit test -- the only difference from the second unit test is that it explicitly sets the boundary string to |
@tleyden, this bug report is already way above normal quality-wise, but if I could be greedy: can you whittle it down to a single file with no external data dependencies, suitable for writing a TestFoo(t *testing.T) function out of? Or even something that would work in play.golang.org? That's 95% of the work of fixing bugs, usually, writing a reproducible small test case. |
Yeah np, I'll give it a shot and post to the issue if I can come up with something. |
OK I managed to remove the external file dependencies and replaced them with zero'd out byte slices, and it's still reproducing the issue. Admittedly it's still a bit clunky since it starts an http listener and goes through a client round trip. |
@tleyden I tried running your TestReadMultipartBody4 against Go commit 801bebe and the test passed correctly. What version are you testing against?
|
I'm on go 1.5.3 on OSX:
I downloaded it from here and built it from source using |
I'm able to reproduce the issue at go1.5.3, but the test passes against HEAD (~go1.6). The question is whether it is worth fixing and releasing Go 1.5.4, or whether we should just recommend upgrading to go1.6, which should be out in a couple of weeks. |
I don't remember fixes to this code this cycle. Did you narrow down which commit is responsible? |
I'll try bisecting. |
Looks like the fix happened in commit 821b549 |
Since this is fixed at HEAD, and Go 1.6 will be released soon, I'll close this issue. |
Works for me. Thanks for getting to the bottom of this! |
I'm seeing unexpected behavior with the Go HTTP MultipartReader when doing
multipart/related PUT
requests to a REST api which contain 1 JSON part and 3 image parts. When callingreader.NextPart()
, it seems to be returning data for both the 3rd and the 4th parts rather than just the 3rd part. After digging into it further, I noticed that the data it returns for part 3 contains the boundary string itself, which definitely seems like it's breaking the parsing.I've only seen this happen rarely, so I think it's dependent on the actual content of the data.
go1.5.1 darwin/amd64
Steps to reproduce:
reader.NextPart()
contain the boundary stringA hypothesis:
I did notice that this particular image data happens to contain the byte sequence for
\r\n
:Could that be causing this line in multipart.go to incorrectly segment it?
I'd be more than happy to try to distill this down to a repeatable unit test with no external dependencies.
The text was updated successfully, but these errors were encountered: