Closed
Description
I've noticed this while digging into #26521 but afaict ParseMediaType behaves correctly according to RFC 2045 but the FormDataContentType doesn't return quoted-string. The function mentions that it formats according to Content-Type
header but RFC 2616 Sect. 2.2 also excludes special characters
for use in token
and must be part of a quoted-string
as well.
What version of Go are you using (go version
)?
go 1.10.3
Does this issue reproduce with the latest release?
Yes.
What did you do?
package main
import (
"mime/multipart"
"mime"
"os"
"fmt"
)
func main() {
w := multipart.NewWriter(os.Stdout)
err := w.SetBoundary("(boundary)")
fmt.Println(err)
ct := w.FormDataContentType()
_, _, err = mime.ParseMediaType(ct)
fmt.Println(ct, err)
}
(https://play.golang.org/p/5ZPC_EGHODn)
What did you expect to see?
multipart/form-data; boundary="(boundary)"
What did you see instead?
multipart/form-data; boundary=(boundary)
Which according to RFC 2045 and RFC 2616 is illegal as (
belongs to special characters that are only allowed in quoted-strings.