Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mime: be stricter parsing media types #3562

Closed
bradfitz opened this issue Apr 24, 2012 · 5 comments
Closed

mime: be stricter parsing media types #3562

bradfitz opened this issue Apr 24, 2012 · 5 comments

Comments

@bradfitz
Copy link
Contributor

This shouldn't be valid:

http://play.golang.org/p/IQ8GeEmP1_

    t, params, err := mime.ParseMediaType(`image/'><style type="text/css">td{background-color:red}</style>`)   
    fmt.Printf("t=%q, p=%v, err=%v", t, params, err)

        t="image/'><style type=\"text/css\">td{background-color:red}</style>", p=map[], err=mime: unexpected content after media subtype


according to: http://www.ietf.org/rfc/rfc1521.txt
@rsc
Copy link
Contributor

rsc commented Apr 25, 2012

Comment 1:

It's not valid: there's an error returned.

@bradfitz
Copy link
Contributor Author

Comment 2:

yeah, but it'd still be nice if t and params were zero values when err != nil.  I know
that's not documented, but it's more consistent with how errors normally work, and it's
halfway implied by the docs saying that a non-nil map is returned when err == nil.
Feel free to close if you disagree.

@rsc
Copy link
Contributor

rsc commented Apr 25, 2012

Comment 3:

agreed

@bradfitz
Copy link
Contributor Author

Comment 4:

This issue was closed by revision 7f7a70f.

Status changed to Fixed.

@rsc
Copy link
Contributor

rsc commented Apr 25, 2012

Comment 5:

This issue was closed by revision b0c2507ec455.

@bradfitz bradfitz self-assigned this Apr 25, 2012
rsc added a commit that referenced this issue May 11, 2015
… error

««« CL 6119051 / 1384d7510575
mime: make ParseMediaType return zero results on error

Fixes #3562

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/6119051
»»»

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6127045
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants