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: ParseMedia fails to parse googleapis batch boundary #8532

Closed
gopherbot opened this issue Aug 15, 2014 · 6 comments
Closed

mime: ParseMedia fails to parse googleapis batch boundary #8532

gopherbot opened this issue Aug 15, 2014 · 6 comments

Comments

@gopherbot
Copy link

by sergiusens:

When using Google's batch API for GMail, the responses contain a ContentType that looks
like this:

multipart/mixed; boundary=batch_Qau-LYGqak0=_AApYZR4VvsU=

This fails to work with ParseMediaType with an error of

mime: invalid media parameter

Here's a playground example: http://play.golang.org/p/3p6UFZau34

Removing the '='s from the boundary lead to a successful parsing of the Content Type.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@bradfitz
Copy link
Contributor

Comment 2:

Google really sends that? That looks illegal.
RFC 2045 says:
     content := "Content-Type" ":" type "/" subtype
                *(";" parameter)
                ; Matching of media type and subtype
                ; is ALWAYS case-insensitive.
     parameter := attribute "=" value
     attribute := token
                  ; Matching of attributes
                  ; is ALWAYS case-insensitive.
     value := token / quoted-string
     token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
                 or tspecials>
     tspecials :=  "(" / ")" / "<" / ">" / "@" /
                   "," / ";" / ":" / "\" / <">
                   "/" / "[" / "]" / "?" / "="
                   ; Must be in quoted-string,
                   ; to use within parameter values
So looking at the boundary part in your example above, it's not quoted, so it's not a
quoted string, which means it must be a token.
But a token excludes tspecials, and "=" is a tspecial.
Hence, invalid.
Please demonstrate how Google sends this and I'll try to kick somebody to fix it.

Owner changed to @bradfitz.

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 3 by sergiusens:

Right, if google returned the boundary quoted, it would work fine:
http://play.golang.org/p/ngT5gWKjWh
Here's a short hackish example where I've included the response dump for
when I run it:
https://gist.github.com/sergiusens/7f75c3593710e1f40abc
I used this as a guide https://developers.google.com/gmail/api/guides/batch

@bradfitz
Copy link
Contributor

Comment 4:

Thanks for the report.
I filed an internal bug.
Google employees can follow along at go/8532-to-internal

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 5:

The regression has been identified internally and a fix is in review.

@bradfitz
Copy link
Contributor

Comment 6:

The fix & tests have been submitted internally. They'll be live whenever they do their
next push.
Closing this bug, as Go's doing the right thing.
Thanks again for reporting.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 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