golang/go

mime: Parse/Format corrupt parameters

dvyukov opened this issue · 1 comments

The following program fails with the panic:

package main

import (
    "mime"
    "fmt"
)

func main() {
    sdata := "0/0;0*=0"
    mt, params, err := mime.ParseMediaType(sdata)
    if err != nil {
        return
    }
    sdata1 := mime.FormatMediaType(mt, params)
    _, _, err = mime.ParseMediaType(sdata1)
    if err != nil {
        fmt.Printf("%q(%q, %+v) -> %q\n", sdata, mt, params, sdata1)
        panic(err)
    }
}
"0/0;0*=0"("0/0", map[0:]) -> "0/0; 0=\"\""
panic: mime: invalid media parameter

Either Format/Parse must preserve parameters, or if that's incorrect input the first Parse must fail.

go version devel +514014c Thu Jun 18 15:54:35 2015 +0200 linux/amd64

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