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: Doesn't sort headers before writing. #13522

Closed
sthulb opened this issue Dec 7, 2015 · 5 comments
Closed

mime/multipart: Doesn't sort headers before writing. #13522

sthulb opened this issue Dec 7, 2015 · 5 comments
Milestone

Comments

@sthulb
Copy link
Contributor

sthulb commented Dec 7, 2015

Problem: The Writer.CreatePart func in mime/multipart doesn't sort before writing headers.

Proposed solution is to obviously sort them and write them in the sorted order, allowing things like unit tests to accurately check if the resulting document is valid.

This is clearly a known issue as the source code has a comment stating this (https://golang.org/src/mime/multipart/writer.go#L97)

    97      // TODO(bradfitz): move this to textproto.MimeHeader.Write(w), have it sort
    98      // and clean, like http.Header.Write(w) does.
    99      for k, vv := range header {
   100          for _, v := range vv {
   101              fmt.Fprintf(&b, "%s: %s\r\n", k, v)
   102          }
   103      }

cc: @bradfitz

@sthulb
Copy link
Contributor Author

sthulb commented Dec 7, 2015

I'm happy to create the patch to fix this, but I understand the stdlib is not accepting changes, I could implement the sort in mime/multipart if required.

@bradfitz bradfitz added this to the Go1.7 milestone Dec 7, 2015
@bradfitz
Copy link
Contributor

bradfitz commented Dec 7, 2015

Feel free to fix this. It can't be submitted until early February, though, so no rush.

@sthulb
Copy link
Contributor Author

sthulb commented Dec 7, 2015

@bradfitz With the new public Write func?

@bradfitz
Copy link
Contributor

bradfitz commented Dec 7, 2015

No new API surface.

@sthulb
Copy link
Contributor Author

sthulb commented Dec 7, 2015

Submitted to Gerrit as: https://go-review.googlesource.com/#/c/17497/

@golang golang locked and limited conversation to collaborators May 16, 2017
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

3 participants