mirror of https://github.com/golang/go.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 <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ec4062f8ea
commit
1ef3a77e18
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue