Skip to content
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

mime/multipart: two boundaries can't have the same prefix #10616

Closed
kgilonne opened this issue Apr 29, 2015 · 7 comments
Closed

mime/multipart: two boundaries can't have the same prefix #10616

kgilonne opened this issue Apr 29, 2015 · 7 comments
Milestone

Comments

@kgilonne
Copy link

Hello,
I encounter difficulties to parse a MIME file, due to 2 boundaries:.

Content-Type: multipart/related; boundary="----=_NextPart_eedf1356402a50765728c12998413837"
Content-Type: multipart/alternative; boundary="----=_NextPart_eedf1356402a50765728c12998413837_alt"

It throws the error: "unexpected EOF"
And finally, after several test, I have found that it's because the first is the prefix of the second and mime/multipart package which looking for boundaries with bytes.Index(...) (multipart.go l.174).

@bradfitz
Copy link
Contributor

Do you have the complete input file, or a minimal repro? What generated it?

Is this a multipart document embedded in a multipart part?

I can imagine what the bug might be, but I'd still like to have a repro case. It would save me time trying to generate it.

@bradfitz bradfitz added this to the Go1.5Maybe milestone Apr 29, 2015
@kgilonne
Copy link
Author

MIME-Version: 1.0
X-Mailer: PHP/5.4.25
Content-Type: multipart/related; boundary="----=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9"

------=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9
Content-Type: multipart/alternative; boundary="----=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9_alt"

------=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9_alt
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

This is a multi-part message in MIME format.

------=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9_alt
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 8bit

html things
------=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9_alt--
------=_NextPart_4c2fbafd7ec4c8bf08034fe724b608d9--

@bradfitz
Copy link
Contributor

Thanks.

@kgilonne
Copy link
Author

This fix works for me:
https://play.golang.org/p/p4-qqQLEW5

At the line 36,
I check if the nlDashBoundary is found and terminated by a '\n'
else if the dashBoundaryDash is found.

@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

Too late for Go 1.5.

@rsc rsc modified the milestones: Go1.6, Go1.5Maybe Jun 29, 2015
@bradfitz
Copy link
Contributor

@rsc, I have a fix for this at https://go-review.googlesource.com/11811 and it'd still be nice to get into Go 1.5 since this isn't some hypothetically fuzzer case, but generated by a real client library, and this is our fault.

@bradfitz bradfitz modified the milestones: Go1.5Maybe, Go1.6 Jun 30, 2015
@gopherbot
Copy link

CL https://golang.org/cl/11811 mentions this issue.

@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Jul 9, 2015
@golang golang locked and limited conversation to collaborators Jul 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants