Skip to content

mime: ParseMediaType rejects valid boundaries #26521

@crawshaw

Description

@crawshaw
contentType := "multipart/alternative; boundary=(boundary)"
_, _, err := mime.ParseMediaType(contentType)

// err = mime: invalid media parameter

https://play.golang.org/p/tC-Ri26iiTo

Looking at RFC 2046, parentheses are valid boundary characters:

boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
                 "+" / "_" / "," / "-" / "." /
                 "/" / ":" / "=" / "?"

https://tools.ietf.org/html/rfc2046#section-5.1.1:

Indeed, the SetBoundary function in the multipart package checks the boundary is valid, and explicitly lets '(' and ')' pass through.

If someone else double-checks my work and confirms this is a bug, I'm happy to fix it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions