From: Patrick Pelletier Date: Thu, 26 Jan 2017 06:09:26 +0000 (-0800) Subject: mime/multipart: allow boundary len <= 70 X-Git-Tag: go1.9beta1~1820 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1ef3a77e182b322eaaaf767eb176a093f5f68282;p=gostls13.git mime/multipart: allow boundary len <= 70 As per RFC 2046, the boundary for multipart MIME is allowed up to 70 characters. The old SetBoundary implementation only allowed up to 69 so this bumps it to the correct value of 70. The relevant RFC is at https://www.ietf.org/rfc/rfc2046.txt and section 5.1.1 defines the boundary specification. Fixes #18793 Change-Id: I91d2ed4549c3d27d6049cb473bac680a750fb520 Reviewed-on: https://go-review.googlesource.com/35830 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/mime/multipart/writer.go b/src/mime/multipart/writer.go index f82756d551..44e2f1bce3 100644 --- a/src/mime/multipart/writer.go +++ b/src/mime/multipart/writer.go @@ -41,13 +41,13 @@ func (w *Writer) Boundary() string { // // SetBoundary must be called before any parts are created, may only // contain certain ASCII characters, and must be non-empty and -// at most 69 bytes long. +// at most 70 bytes long. func (w *Writer) SetBoundary(boundary string) error { if w.lastpart != nil { return errors.New("mime: SetBoundary called after write") } // rfc2046#section-5.1.1 - if len(boundary) < 1 || len(boundary) > 69 { + if len(boundary) < 1 || len(boundary) > 70 { return errors.New("mime: invalid boundary length") } for _, b := range boundary { diff --git a/src/mime/multipart/writer_test.go b/src/mime/multipart/writer_test.go index 9670c660a4..23e650f5e4 100644 --- a/src/mime/multipart/writer_test.go +++ b/src/mime/multipart/writer_test.go @@ -90,8 +90,8 @@ func TestWriterSetBoundary(t *testing.T) { {"", false}, {"ungültig", false}, {"!", false}, - {strings.Repeat("x", 69), true}, - {strings.Repeat("x", 70), false}, + {strings.Repeat("x", 70), true}, + {strings.Repeat("x", 71), false}, {"bad!ascii!", false}, {"my-separator", true}, }