Skip to content

mime: ParseMediaType parses invalid media types #11289

Description

@dvyukov

The following program fails with the panic:

package main

import (
    "mime"
    "fmt"
)

func main() {
    sdata := "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", map[]) -> ""
panic: mime: no media type

If "0" is not a valid mediatype, then the first ParseMediaType should produce an error.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions